Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python programming you should use While loop For loop Range() Break Continue A Fluky Number is a number that is equal to the sum of

python programming

you should use

  • While loop
  • For loop
  • Range()
  • Break
  • Continue

A Fluky Number is a number that is equal to the sum of a set of random numbers, where the random numbers are the first random numbers generated after seeding a random number generator with each factor of the number, not including itself. That's quite a mouthful, so here it is again in simpler terms. All of the following requirements must be met for a number to be a Fluky Number.

  1. A Fluky Number is a number, called The Number, that is equal to the sum of a set of randomly generated numbers.
  2. Random numbers are generated with a random number function. We will use randint() from the random module.
  3. The randomly generated numbers are in the range of 1 to the The Number, inclusive. (Ex. If The Number is 10, the random number can be 1 through 10, including 1 and 10)
  4. Random numbers are the first number generated after setting a specific seed value (Use the random.seed() function).
  5. The seed values are all of the factors of The Number, not including itself. (Ex. The factors of the number 10 that will be used for the seed are 1, 2, and 5)

You must write a program to find all Fluky Numbers from 1 to 10000. As a tip to help make sure you're on the right track, the first 3 Fluky Numbers are: 8, 22, and 25. Your program must discover these numbers, you may NOT use code such as the following:

if testNum == 8: print("Found a Fluky Number!")

You may know that there are 7 Fluky numbers between 1 and 10000.

Your program must print the total running time in seconds to two decimal places. It must print the total number of inner loops executed. Here is an example output, without actual numbers showing: (Note: An 'X' does not indicate the number of digits or any other meaning. It's just a filler)

Fluky Number: 8 Fluky Number: 22 Fluky Number: 25 Fluky Number: XX Fluky Number: XX Fluky Number: XX Fluky Number: XX Total Time: XX.XX seconds Total Loops: XXXXXXXXXXX

See Rubric for all requirements. Make sure to catch the points for reducing the number of required loops.

NOTE: Your code must discover all seven Fluky Numbers using a nested loop structure. You cannot use any information about the properties of Fluky Numbers other than what is described. Your program may know that there will be exactly seven Fluky Numbers numbers with values of 10,000 or less. You may use basic math/logic principles to help you reduce the number of iterations. If you're reading through Wikipedia or doing google searches then you are over-thinking it. Think through in your planning how you can reduce the number of iterations without affecting the results...and think simply.

Find the 7 Fluky Numbers Properly

under 2,000,000 loops

Print total number of iterations of inner loop

Print total running time message

print in seconds with two decimal places

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Is there any dispute that this is the cause?

Answered: 1 week ago