+ 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?
17 Answers
+ 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
+ 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..
+ 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)
+ 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.
+ 2
Abhay yes it works nicely, tell me you can do another 1-2 lines of code, is it possible?
+ 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
+ 1
,Jayakrishna🇮🇳 can I do without a cycle?
+ 1
Jayakrishna🇮🇳 understood.
0
royal koli
0
Muje
0
Koding
0
Now we need Jan Markus [PRO_crastinator] to tell us which is most efficient 🙂