#Assignment 1 - Program to check given number is Armstrong or not
num = int(input("Enter a number: "))
# initializing sum
sum = 0
# find the sum of the cube of each digit(to understand whether given number is a Armstrong or not)
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
# display the result
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
Enter a number: 850 850 is not an Armstrong number
#Assignment-1(b)
# Program to display the Fibonacci sequence up to n-th term
import math
nterms = int(input("enter number of terms to generate fibonacci series "))
# first two terms
n1, n2 = 0, 1
count = 0
# check if the number of terms is valid
if nterms <= 0:
print("Please enter a positive integer")
# if there is only one term, return n1
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence is:")
while count < nterms:
print(n1)
nth = n1 + n2
# update values
n1 = n2
n2 = nth
count += 1
enter number of terms to generate fibonacci series 7 Fibonacci sequence is: 0 1 1 2 3 5 8