Lab 7 – Python
Loading...
Answer;
Q1
* | ||||
* | * | |||
* | * | * | ||
* | * | * | * | |
* | ||||
* | * | * | ||
* | * | * | * | * |
* | * | * | ||
* |
Q2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | primes = [] N = int(input( "Please enter a number greater than 1: " )) D=N F = 2 while N > 1: #Check if F divides N if N // F == N / F: primes.append(str(F)) N = N // F else : #increase F by 1 F += 1 answer = "," .join(primes) print ( "The prime factors of " ,D, " are " , answer) |
Leave a reply