-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathStrong Numbers.cpp
More file actions
42 lines (42 loc) · 847 Bytes
/
Copy pathStrong Numbers.cpp
File metadata and controls
42 lines (42 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
using namespace std;
int Fictorial(const int& num)
{
int fictorial = 1;
for (int i = 1; i <= num; i++)
{
fictorial = fictorial * i;
}
return fictorial;
}
bool Check_Strong_Number(const int& num)
{
int number = num, sum = 0, remainder;
while (number != 0)
{
remainder = number % 10;
number = number / 10;
sum = sum + Fictorial(remainder);
}
if (sum == num)
{
return 1;
}
else
return 0;
}
int main()
{
int number;
cout << " -------------------------------" << endl;
cout << "\tCheck Strong Numbers" << endl;
cout << " -------------------------------" << endl;
cout << "Enter a Number: ";
cin >> number;
if (Check_Strong_Number(number))
{
cout << number << " is Strong number" << endl;
}
else
cout << number << " is not a Strong number" << endl;
}