+ 1

Whats the algorithm for factorial,armstrong number?

10th Jun 2018, 5:08 AM
omprakash prajapati
omprakash prajapati - avatar
3 Antworten
+ 6
Factorial refers to the product of all positive integers that are less than or equal to a specific non-negative integer (n). The factorial of n is denoted as n! There 5! =5*4*3*2*1 There you have to make recursive function to output it. There will be a base case that when the number is equal or less than 0 it will return 1. Else it will return n*recursivefunction (n-1). That's it.
10th Jun 2018, 5:16 AM
Akash Pal
Akash Pal - avatar
+ 6
For Armstrong Numbers, see this Challenge. https://www.sololearn.com/learn/4708/?ref=app You will just have to split the numbers into digits and then have to raise it to the power of its length and then have to add them. If the output is same to the number, it is a Armstrong Number.
10th Jun 2018, 5:19 AM
Akash Pal
Akash Pal - avatar
+ 1
👍
10th Jun 2018, 1:28 PM
omprakash prajapati
omprakash prajapati - avatar