def FR(T, P, Y,):
    G = 0
    S = 1
    
    for i in range(P):
        S = 10 ** (-i)
        for _ in range(10):  
            if (G + S) ** Y > T:
                break  
            G += S
    
    return G

print(FR(27, 3, 3))  # 2.999... (ほぼ3)

def FL(T, P, Y,):
    G = 0
    S = 1
    
    for i in range(P):
        S = 10 ** (-i)
        for _ in range(10):  
            if Y ** (G + S) > T:
                break  
            G += S
    
    return G
print(FL(1000, 10, 10))  # 2.999... (ほぼ3)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: