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 is the importance of c in your views?

1094


Explain how can I make sure that my program is the only one accessing a file?

1167


Difference between Function to pointer and pointer to function

1019


Is c call by value?

967


Is c still used?

999


Explain how can I right-justify a string?

992


How important is structure in life?

1028


What is a global variable in c?

954


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2079


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

1070


What is a newline escape sequence?

1055


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2561


Is array name a pointer?

994


Should a function contain a return statement if it does not return a value?

1017


Is multithreading possible in c?

949