- 2
Guyz can't stuck at this ?
3. Calculate the arithmetic sequence of n numbers. The program will generate the nth term of the sequence, whereas the user will enter the first term and the common difference. Example: you have entered the first term as 3 and common difference 6 you are interesting in 35 term. So it will calculate and generate the answer as 207. anat (n-1)d
9 ответов
+ 1
# Hi! Your almost there!
# an = a0 + d*(n - 1)
# a0 = 3, d = 6 -> a35 = 3 + 6*(35 - 1) = 207
# Just write a function to put the formula in!
+ 1
Really appreciate brother many many thanks.
+ 1
Rit Wittkopp
he wrote it wrong
n + (n - 1)d
35 + (35- 1)6
0
SAfiullaH KhoKhar
Hi buddy
Call me dumb, but I don't understand how you get 207 from the first 2 inputs of 3 & 6.
Could you break it down for us please.
0
Brother there's a formula to find the nth term
0
a=2+6(n-1)
0
a=6n-4
0
Our nth term is 35 like mentioned in the question so,
a=6*35-4
206 is the answer.
0
Your question formation is wrong first you asked for nth term but you wanted to print the value in the nth term both are different.
a=int(input(Enter the first term:))
d=int(input(Enter the common difference:))
n=int(input(Enter the nth term value you want))
Ap=a+((n-1)*d)
Print(Ap)