Strong number is a number whose sum of all digits’ factorial is equal to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120)
More...
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
Strong number is a number whose sum of all digits’ factorial is equal to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120)
◆ isStrong()
bool isStrong |
( |
int |
number | ) |
|
Check if given number is strong number or not.
- Parameters
-
- Returns
true
if given number is strong number, otherwise false
22 int originalNumber = number;
23 while (originalNumber != 0)
25 int remainder = originalNumber % 10;
26 int factorial = remainder == 0 ? 0 : 1;
29 for (
int i = 1; i <= remainder; factorial *= i, i++)
◆ main()
Driver Code.
- Returns
- None
void test()
Test function.
Definition: strong_number.c:43
◆ test()
Test function.
- Returns
- void
bool isStrong(int number)
Check if given number is strong number or not.
Definition: strong_number.c:15