Who Needs 3's, 6's, or 9's?!!
This challenge is based on the following tweet:
Write a program that prompts for the maximum number of digits to (max_digits
) be used in each of the numerator and the denominator, then randomly create a fraction with that number of digits. Let's call this the simple_fraction
.
Now add at least max_digits
3's, 6's, or 9's randomly to each of the numerator and denominator, as shown in the diagram above. Let's call this the complex_fraction
.
Now compare the quotient of both the simple_fraction
and the complex_fraction
. If they are the same, output "They are the same!". If they are different, output "The quotients are _____ and _____ so they are not the same!", where the underscores are simple_fraction
and complex_fraction
rounded to 5 decimal places, in that order.
If instructed, do this challenge as a Google Colab notebook. A template for this has been created here (make a copy: File > Save a copy in Drive).
See below for details: