# Compatible in Python 2.7
k=int(raw_input('Enter the range of number:'))
for n in range(k):
sum=0
temp=n
y=len(str(n))
while(n>0):
R=n%10
V=R**y
sum=sum+V
n=n/10
if (sum==temp):
print 'Armstrong Number',temp
Solve Problems by Coding Solutions - A Complete solution for python programming
Fibonacci sequence using functions for N numbers
# Compatible in Python 2.7
def recur_fibo(n):
if n <= 1:
return n
else:
return(recur_fibo(n-1) + recur_fibo(n-2))
nterms = int(input("How many terms? "))
if nterms <= 0:
print "Plese enter a positive integer"
else:
print "Fibonacci sequence:"
for i in range(nterms):
print recur_fibo(i)
Subscribe to:
Posts (Atom)