here is the question which i am trying to solve is,
what comes next after 2,3,10,15,26,35,50, ?
Actually the sequence is like this:
1*1+1=2
2*2-1=3
3*3+1=10
4*4-1=15
5*5+1=26
6*6-1=35
7*7+1=50
So next sequence will be-
8*8-1=63
I am trying to solve this in pythonic way but i'm getting nothing output as expected:
n = int(input("enter a number: "))
def solve_problem(n):
for x in range(n):
if x % 2 == 0:
return (lambda x: x**2-1)
else:
return (lambda x: x**2+1)
solve_problem(n)
It would be great if anybody could figure me out where i'm doing thing wrong. thank you in advance!