help friends | SoloLearn: Learn to code for FREE!

+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?

3/4/2021 8:26:18 PM

Aid

17 Answers

New Answer

+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

+9

Recursive aproch t=int(input()) k=int(input()) def recur(t,k): if k==0: return 1 else: return (t+k)*recur(t,k-1) print(t*recur(t,k-1)) https://code.sololearn.com/c6srnGygYFuz/?ref=app

+5

t=int(input()) k=int(input()) temp=t for i in range(1,k): t*=(temp+i) print(t)

+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?

+2

Thanks ALLAH solved by one line just! >>>print(eval('*'.join(list(map(lambda x:str(x[0]+x[1]),enumerate([int(input())]*int(input()))))))) Aid

+2

Aid Here's my try , please have a look here 👇 import math a=int(input()) b=int(input()) c=math.prod(range(a,a+b)) print(c)

+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

0

0

Now we need Jan Markus [PRO_crastinator] to tell us which is most efficient 🙂

-2

In the name of kindly generous ALLAH Thanks ALLAH Hello Aid can you explain more? please...