What two whole, positive numbers that have a one-digit answer when multiplied and a two-digit answer when added?
riddle source:http://riddles.com/
How to?
We need to declare 2 variablesum
andmult
:
sum
is to check thesum of the 2 digits.mult
is to check themultiplication of the 1 digit.
And both should be assigned as 0.
sum=0mult=0
Now we need 2 for loops to iterate through the needed numbers
The numbers should be between 1 and 9, beacuse their multiplication should be only 1 digit.
1-Any number multiplied by 0 will result 0
2-Any number less than 10 multiplied by 10 or a number greater than 10 will result to number of 2 digits
forxinrange(1,10):foryinrange(1,10):sum=x+ymult=x*yif(sum>=10):if(mult<10):print(str(x)+" and "+str(y))break
And finally we need to break the iteration at the end of the second loop to avoid iterating through the same numbers twice.
Answer
>9 and 1
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse