Lab 7 – Python
Lab 7
Answer;
Q1
* | ||||
* | * | |||
* | * | * | ||
* | * | * | * | |
* | ||||
* | * | * | ||
* | * | * | * | * |
* | * | * | ||
* |
Q2
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