Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The result is not displayed, the explanation of the program is in code. Here's the code in text and as screenshot. #This is a program

The result is not displayed, the explanation of the program is in code.

Here's the code in text and as screenshot.

#This is a program to prompt user to input a natural number #and return the greatest nontrivial factor of that number.

def main(): # get n n = int(input("Please enter a natural number: ")) # compute the greatest nontrivial factor factor = greatest_trivial_factor(n) # Display the greatest non-trivial factor of the entered number def getInputs(): n = int(input("Please enter a natural number: ")) def greatest_trivial_factor(n): factor = 0 print ("The greatest trivial factor of ",n," is") ''' Calculate the greatest trivial factor of n and check if current factor is greater than previous factor Parameters: n -- natural number Return F ''' i = 1 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. factor = i i=i+1 if(factor != 1 and factor != n and factor != 0): return factor def displayResults(factor): output=(greatest_trivial_factor(n))# store result of function in output varriable print (output) #printing result

# Call the main function to execute the program if __name__ == "__main__": main()

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

5. What information would the team members need?

Answered: 1 week ago