E D R S I H C RSS
ID
Password
Join
Your own qualities will help prevent your advancement in the world.

FrontPage 단위분수를소수로변환하기

def getDecimal(q, size):
    
    if (q < 2):
        return -1
    
    p = 10
    result = "0."
    
    for i in range(size):
        m = p % q
        
        result += str(int(p / q))
        if (m == 0):
            break;
        else:
            p = m * 10
    
    return result
    

    
for i in range(2, 10):
    print(str(i) + " : " + getDecimal(i, 100) )
    
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2016-09-07 02:41:06
Processing time 0.0263 sec