#To find the nth bell number
a=[]
n=input()
if n==0:
a.append(1)
else:
for i in range(1,n+1):
if len(a)==0:
a.append(1)
leng = 1
start = 0
else:
last=a[len(a)-1]
j=0
index = start
while j!=leng:
element = last+a[index]
a.append(element)
index+=1
j+=1
last= a[len(a)-1]
start = len(a) - leng -1
leng +=1
print a[len(a)-1]
a=[]
n=input()
if n==0:
a.append(1)
else:
for i in range(1,n+1):
if len(a)==0:
a.append(1)
leng = 1
start = 0
else:
last=a[len(a)-1]
j=0
index = start
while j!=leng:
element = last+a[index]
a.append(element)
index+=1
j+=1
last= a[len(a)-1]
start = len(a) - leng -1
leng +=1
print a[len(a)-1]
No comments:
Post a Comment