← RU Pythoncursus

Uitwerking: Priemfactorontbinding

import time

print('give a number to factorize')
x = int(input())
print(x, '=', end='')
i = 2
starttime = time.time()
while x > 1:
    if x % i == 0:
        print(str(i), end = '')
        x = x // i
        if x != 1:
            print('*', end = '')
    else:
        i = i+1

print('\nruntime: ' + (str(time.time() - starttime)) + ' seconds')