# Program using Iteration

1. Program to print Even  Numbers up to N
N=int(input(“enter number “))
for i in range(2,N,2):
—-print(i,end=” “)

Q2. Program to print Fibonacci Series 0,1,1,2,3,5,8,13…….

no1=1
no2=2
print(” ,+ no1)
print(‘\n’,+no2)
x=1
while(x<=10):
no3=no1+no2
no1=no2
no2=no3
print (‘\n’,+no3)
x=x+1

Q3 Program to print First 10 Natural Numbers

print (‘First 10 Natural Numbers are ‘)
for i in range(1,11) :
—- print (i)

Q4, Program to print Multiplication Table of a Given Numbers

a=int(input(‘Enter a Number’))
i=1
while i<=10:
t=a*i
print (“%d X %d = %d ” % (a,i,t))
i=i+1

Q5 Program to check whether the given no. is Prime or not (Method I)

no=int(input(“Enter Number : “))
for i in range(2,no):
ans=no%i
if ans==0:
print (‘Non Prime’)
break
elif i==no-1:
print(‘Prime Number’)

(II Method)

n=int(input(“enter the no “))
f=0
if n==1 or n==0 :
print(“No is not complex nor composite”)
elif n>=2 :
for i in range(2, (n+1)/2):
if n%i==0 :
f=1
break
if f==0 :
print(“It is Prime Number”)
else :
print(“it is not a Prime Number”)

Q6. Program to Calculate Factorial of a given Number

a=int(input(‘Enter a Number to calculate factorial’))
f=1
while (a> 1):
f=f*a
a=a – 1
print (‘FActorial is %d’%(f))

Q7. Program to print First 10 Natural Numbers in reverse Order.

print (‘First 10 Natural Numbers are ‘)
for i in range(10,0,-1) :
print (i)

Q8. Write a Program to find smallest among given numbers

sm=int(input(‘Enter :’))
for i in range ( 1,10):
n=int(input(‘Enter :’))
if n<sm:
sm=n
print (“Smallest number is %d” % (sm))

Q9 Program to check whether the given number is an Armstrong Number

no=int(input(“Enter any number to check : “))
no1 = no
sum = 0
while(no>0):
ans = no % 10;
sum = sum + (ans * ans * ans)
no = int (no / 10)
if sum == no1:
print(“Armstrong Number”)
else:
print(“Not an Armstrong Number”)

Q10 Prpgram to print series of Prime Numbers between 1 to 100

for i in range(1,101):
for j in range(2, i):
ans = i % j
if ans==0:
print (i,end=’ ‘)
break

11. Program to print Odd  Numbers up to N
N=int(input(“enter number “))
for i in range(1,N,2):
print(i,end=” “)

##### 12.Program to print Series 1 4 7 10 13…….N

n=int(input(“enter the number “))
for i in range(1, n+1, 3):
print(i,end=” “)

##### 13.Program to calculate x to the power y

x=int(input(“enter the no “))
y=int(input(“enter the no “))
p=1
for i in range(1, y+1):
p*=x
print(p)

##### 14 Program to calulate LCM and GCD

n1=int(input(“enter the no “))
n2=int(input(“enter the no “))
gcd=lcm=r=n=d=0
if n1>n2 :
n=n1
d=n2
else :
n=n2
d=n1
r=n%d
while r!=0 :
n=d
d=r
r=n%d
gcd=d
lcm=n1*n2/gcd
print((“GCD of %d and %d=%d\n”)%(n1,n2,gcd))
print((“LCM of %d and %d=%d\n”)%(n1,n2,lcm))