subject

Factoring of integers. Write a python program that asks the user for an integer and then prints out all its factors. For example, when the user enters 150, the program should print 2 3 5 5. This is just a pseudocode for visual:
Get a value from user Print
"The factors are: "
Keep going while the value is greater than 1
Start the divisor at 2 A factor has not been found Keep going until a factor is found
If the value is evenly divisible by the divisor
A factor has been found
Print the divisor Change value to equal value / divisor.
You have now found a factor you want to see if there are factors in the remaining part of the number.
FYI: For instance if the number is 100, your first factor would be 2 and on our second time through you would need to see if there are factors of 50. This would result in another factor of 2 in the third pass and looking for factors of 25. This would result in a factor of 5 in the fourth pass and looking for factors of 5. This would result in value finally = 1 so you are done. If I enter 175, I would see 5, 5, and 7 as my results. Increment the divisor so you can see if the next number is a factor. This statement is not necessary if a factor is found, but it does not matter if it is executed because you will fall out of the inside nested if and reset the divisor to 2 if you come back in.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:20, orlando19882000
The pyraminx is a rubik's cube-type toy in the shape of a tetrahedron (not a pyramid). the pyraminx shown below has edges 15\,\text{cm}15cm15, space, c, m long and vertical height h=12.2\,\text{cm}h=12.2cmh, equals, 12, point, 2, space, c, m. the triangle drawn with dashed lines is a right triangle. what is the distance rrr? round your answer to the nearest tenth.
Answers: 1
image
Computers and Technology, 22.06.2019 01:20, karreemgrant2
What is the full meaning of rfid in computer
Answers: 2
image
Computers and Technology, 22.06.2019 11:30, genyjoannerubiera
What does a cascading style sheet resolve a conflict over rules for an element? a. the rule affecting the most content wins b. the rule affecting the most content loses c. the rule with the most specific selector loses d. the rule with the most specific selector wins
Answers: 2
image
Computers and Technology, 22.06.2019 21:00, briannaleiigh
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
You know the right answer?
Factoring of integers. Write a python program that asks the user for an integer and then prints out...

Questions in other subjects:

Konu
Mathematics, 29.11.2020 14:40