1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dlinn [17]
3 years ago
13

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.
Computers and Technology
1 answer:
Oduvanchick [21]3 years ago
8 0

num = int(input("Enter a number: "))

i = 2

while num > 1:

   if num % i == 0:

       num = num / i

       print(i, end=" ")

       i = 2

   i += 1

I hope this helps!

You might be interested in
Spell checker will find every mistake you make in a document and correct it. A. True B. False
Lilit [14]
Not every. it doesnt find grammar mistakes.
4 0
3 years ago
Read 2 more answers
HELP PLZ ;(
Keith_Richards [23]
The answer is B or you could click when the pop up
8 0
3 years ago
Read 2 more answers
How many nibbles are in 18 bytes??
IgorC [24]
36 Nibbles are in 18bytes.
7 0
4 years ago
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
svlad2 [7]

Answer:

The program in Python is as follows:

currentPrice = int(input("Current: "))

lastMonth = int(input("Last Month: "))

print("The house is $",currentPrice)

print("The change is $",(currentPrice-lastMonth),"since last month")

print("The estimated monthly mortgage is $",(currentPrice * 0.051) / 12)

Explanation:

Get input for current price

currentPrice = int(input("Current: "))

Get input for last month price

lastMonth = int(input("Last Month: "))

Print current price

print("The house is $",currentPrice)

Print change since last month

print("The change is $",(currentPrice-lastMonth),"since last month")

Print mortgage

print("The estimated monthly mortgage is $",(currentPrice * 0.051) / 12)

6 0
3 years ago
How can you identify the active cell in excel
dybincka [34]

Answer:

An active cell refers to the currently selected cell in a spreadsheet. It can be identified by a bold (typically blue) outline that surrounds the cell.

Explanation:

he standard way to reference the location of an active cell is with a column/row combination, such as A2 (first column, second row) or B5 (second column, fifth row). hope this helps you :)

6 0
3 years ago
Other questions:
  • What are two parts of a cell reference?
    7·1 answer
  • If it is impractical to place guest users in a secure network, isolated from the production network by firewall barriers, then:
    14·1 answer
  • It is perhaps not surprising that Etsy was an early adopter of DevOps. It is a relatively small company, with a start-up culture
    7·1 answer
  • Match the definition with the corresponding word
    12·2 answers
  • 1. You are the network manager for a computer training center that allows students to bring their own laptops to class for learn
    5·1 answer
  • How does calculate() work?
    6·2 answers
  • 2. Define a function squareArea that computes the area of a square given side length
    14·1 answer
  • Using the arrow key you can adjust the position of a selection in increments of
    7·1 answer
  • I need a 75 word Radio Ad on Why Technology should be kept in a schools budget.
    11·1 answer
  • Advantages of email over traditional mail​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!