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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value.a member function called setscore that accepts a parameter and assigns it to score . the function returns no value.a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
question
Computers and Technology, 23.06.2019 12:40
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
question
Computers and Technology, 23.06.2019 20:30
What is the biggest difference between section breaks and regular page breaks
Answers: 1
question
Computers and Technology, 24.06.2019 01:10
Create a program that will take in a single x and y coordinate as the origin. after the input is provided, the output should be all of the coordinates (all 26 coordinates read from the “coordinates.json” file), in order of closest-to-farthest from the origin.
Answers: 1
You know the right answer?
Factoring of integers. Write a python program that asks the user for an integer and then prints out...
Questions
question
Chemistry, 03.02.2021 04:10
question
Mathematics, 03.02.2021 04:10
question
Business, 03.02.2021 04:10
question
Mathematics, 03.02.2021 04:10