Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

UglyNumbers/DamienRice

From ZeroWiki
Revision as of 02:08, 23 September 2008 by imported>DamienRice
def ugly(pos):
    count = 0
    uglys = [2,3,5]
    minVal = 0
    while count != pos-1:
        minVal = min(uglys)
        if uglys.count(minVal*2)==0:
            uglys.append(minVal*2)
        if uglys.count(minVal*3)==0:
            uglys.append(minVal*3)
        if uglys.count(minVal*5)==0:
            uglys.append(minVal*5)

        uglys.remove(minVal)
        count += 1

    print minVal

if __name__=='__main__':
    ugly(1550)

UglyNumbers