Question: Write Python code to compute the factors of a positive number N entered by the user. Then the program stores the factors of N as

Write Python code to compute the factors of a positive number N entered by the user. Then the program stores the factors of N as a list. Code uses the len() function to count the elements and reports the number of factors (NF). Example:
If N=7, the factors are: 1,7 and the number of factors is 2. The output is "The number of factors of 7 is 2 and the factors are: [1,7]"
If N=9, the factors are: 1,3,9 and the number of factors is 3. The output is:
"The number of factors of 9 is 3 and the factors are: 1,3,9"
Hint: you can use the module operator %. To determine if the number N is divisible by a factor i, the condition N%i==0 must be True, where i takes successive values: 1,2,dots,N within a loop
If the number has exactly two factors then report "The number xx is prime", otherwise "The number xx is not prime"
 Write Python code to compute the factors of a positive number

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!