Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- using namespace std;
- unsigned long long Fact(unsigned long long);
- int main()
- {
- unsigned long long a, b, c;
- for(a = 1; a <= 1000; a++)
- {
- for(b = 1; b <= 1000; b++)
- {
- for(c = 1; c <= 1000; c++)
- {
- unsigned long long product = (100*a) + (10*b) + (c);
- if(product == (Fact(a) + Fact(b) + Fact(c)))
- {
- cout << "a = " << a << endl;
- cout << "b = " << b << endl;
- cout << "c = " << c << endl;
- cout << endl;
- }
- }
- }
- }
- }
- unsigned long long Fact(unsigned long long number) //factoriel algorithm function
- {
- unsigned long long counter = 1;
- for(unsigned long long i = 1; i <= number; i++)
- {
- counter = counter*i;
- if(counter >= ULONG_LONG_MAX)
- {
- break;
- }
- }
- return counter;
- }
- /*
- ----------------------------------------------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------------------------------------------
- Execise done based on "Algorithms: Write a computer program (or develop an algorithm) to determine whether there is a three-digit integer abc (= 100a + 10b + c) where abc = (a! + b! + c!)?"
- Source: https://www.quora.com/Algorithms/Write-a-computer-program-or-develop-an-algorithm-to-determine-whether-there-is-a-three-digit-integer-abc-100a-+-10b-+-c-where-abc-a-+-b-+-c
- ----------------------------------------------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------------------------------------------
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement