object of this assignment is

 

1. Working with global 'constant'

 

2. Implementing a given algorithm

 

 

 

It is writing python script that asks the user for a positive integer between 1 and 1,000. The script shall print out a list of the prime numbers which are factors of the input value.

 

 

 

for the minimal version

 

 

 

with limt of the first 11 prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31

 

 

 

sample run:

 

Enter a positive integer between 1 and 1,000: 12

 

 

 

2 is a factor of 12.

 

3 is a factor of 12.

 

 

 

standard version

 

It need to be updated the factors function so that it prints out the prime factorization of positive integer between 1 and 1000 that is parameter.

 

 

 

sample:

 

Enter a integer between 1 and 1,000: 12

 

the factors of 12: 2 2 3

 

 

 

Here's the basic algorithm:

 

 

 

1.Store the input (parameter) value.

 

 

 

2.Work through the list of primes in order. We'll work with only one prime at a time. This will be called "current prime".

 

 

 

3.As long as the current prime evenly divides the input value, Output the current prime. Set the input value to its quotient when divided by current prime.

 

 

 

4.When current prime no longer evenly divides the input value, go to the next prime number in the list.

 

 

 

5.Repeat until value is 1.

 

 

 

6.If you reach the end of the list of primes and the input value does not equal one, then that remaining input value is prime. Output that value.

 

    • 10 years ago
    Solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      primefactors_minimal.py_.txt
    • attachment
      primefactors_standard.py_.txt