Question: TIL File Edit Format Run Options Window Help 1 | This is a program to prompt user to input a natural number 2 #and return

 TIL File Edit Format Run Options Window Help 1 | This

TIL File Edit Format Run Options Window Help 1 | This is a program to prompt user to input a natural number 2 #and return the greatest nontrivial factor of that number. 3 4 def main(): # get n n = int(input("Please enter a natural number: ")) 7 # compute the greatest nontrivial factor 8 factor = greatest_trivial_factor (n) 9 # Display the greatest non-trivial factor of the entered number 10 11 def getInputs(): 12 n = int(input("Please enter a natural number: ")) 13 14 def greatest trivial factor (n): 15 factor = 0 16 print ("The greatest trivial factor of ",n," is") 17 18 19 Calculate the greatest trivial factor of n 20 and check if current factor is greater than previous factor 21 Parameters: 22 n -- natural number 23 Return 24 F 25 26 i = 1 27 while(i = factor and i != 1 and i != n): #this checks that the factor is not 1 and number itself because in that case It will not be trivial. 30 factor = i 31 i=i+1 32 if(factor != 1 and factor != n and factor != 0): 33 return factor 34 35 def displayResults (factor): 36 output=(greatest_trivial_factor (n)) # store result of function in output varriable 37 print (output) #printing result 38 39 # Call the main function to execute the program 40 if main 41 main( 42 43 III name ==

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!