Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to check whether a number is Peterson or not.

Answer Posted / prasanna kumar

N = int(input("Enter a number: "))
original_num = N
sum_of_factorials = 0
while N > 0:
digit = N % 10
fact = 1
for i in range(1, digit + 1):
fact = fact * i
sum_of_factorials = sum_of_factorials + fact
N = N // 10
if sum_of_factorials == original_num:
print(f"{original_num} is a Peterson number")
else:
print(f"{original_num} is not a Peterson number")

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what do you mean by enumeration constant?

1018


Write a program that accept anumber in words

1766


What is assert and when would I use it?

1020


What is calloc malloc realloc in c?

1067


What is page thrashing?

1090


What is union in c?

1123


What does c in a circle mean?

1087


What does s c mean on snapchat?

1122


Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?

2700


What is volatile variable in c with example?

1050


Explain Basic concepts of C language?

1168


What is the maximum no. of arguments that can be given in a command line in C.?

1158


How are 16- and 32-bit numbers stored?

1293


When a c file is executed there are many files that are automatically opened what are they files?

1114


How many loops are there in c?

1117