+ 3

help friends

Given 2 numbers: t and k Find the result  t(t+1)(t+2)...(t+k-1). t = int(input()) k = int(input()) print(t**k+t**k+t**k) 2 3 out: 24 what is wrong here or a loop to use?

4th Mar 2021, 8:26 PM
Aid
Aid - avatar
17 odpowiedzi
+ 11
Check this, t = int(input()) k = int(input()) num=list((t+i) for i in range(k)) out=1 for i in num: out*=i
4th Mar 2021, 8:55 PM
Abhay
Abhay - avatar
+ 4
Aid For ex : If t = 2 , and k= 100 , then how can do it without cycle? Its difficult and become redundant code.. Use cycle to make it simple one or two lines of code..
4th Mar 2021, 9:00 PM
Jayakrishna 🇮🇳
+ 3
Do you mean "expand code or reduse"? edit : Aid if you are asking for clear understandings, hope this way helps : t = int(input()) k = int(input()) r=1 for i in range(k): r = r*(t+i) print(r)
4th Mar 2021, 9:43 PM
Jayakrishna 🇮🇳
+ 2
Aid yes. You need to use loop.. For t=2,k=3 2*(2+1)*(2+2) = 2*3*4 = 24 repeat multiply t with next number upto k-1.
4th Mar 2021, 8:53 PM
Jayakrishna 🇮🇳
+ 2
Abhay yes it works nicely, tell me you can do another 1-2 lines of code, is it possible?
4th Mar 2021, 9:05 PM
Aid
Aid - avatar
+ 1
Abol two numbers are given for input, it must be processed in the form so that the number is specifically entered. you need to use a loop or not. my decision is not correct
4th Mar 2021, 8:52 PM
Aid
Aid - avatar
+ 1
,Jayakrishna🇮🇳 can I do without a cycle?
4th Mar 2021, 8:56 PM
Aid
Aid - avatar
+ 1
4th Mar 2021, 9:01 PM
Aid
Aid - avatar
0
royal koli
6th Mar 2021, 3:48 AM
Jaypal Makwana
Jaypal Makwana - avatar
0
Muje
6th Mar 2021, 3:48 AM
Jaypal Makwana
Jaypal Makwana - avatar
0
Koding
6th Mar 2021, 3:48 AM
Jaypal Makwana
Jaypal Makwana - avatar
0
Now we need Jan Markus [PRO_crastinator] to tell us which is most efficient 🙂
6th Mar 2021, 7:26 AM
Steve
Steve - avatar