Python loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python loop

How to find and print 4 numbers, put in a raw consecutively, that multiplied by each other equal to 1680? The output is 5, 6, 7, 8 (i.e. 5*6*7*8=1680)

14th Sep 2020, 12:42 PM
JSiegerheim
2 Answers
+ 1
man, I need a code that calculates these numbers from the statement only. the output is the answer that I found mathematically - I need to do the same math calculations using the code! thanks!
14th Sep 2020, 1:03 PM
JSiegerheim
+ 1
I have changed your script a little bit in accordance with the statement and it worked perfectly! THANK YOU, MAN!: num = 1680 x = 0 for i in range(1,num-3,1): a,b,c,d = i,i+1,i+2,i+3 pro = a*b*c*d if pro == num: print(a,"*",b,"*",c,"*",d) x = 1
14th Sep 2020, 2:35 PM
JSiegerheim