Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string strong;
- cin >> strong;
- int number = stoi(strong), sum = 0;
- for (int i = 1; i <= strong.length(); i++) {
- int factorial = 1;
- for (int j = 1; j <= number % 10; j++) {
- factorial *= j;
- }
- sum += factorial;
- number /= 10;
- }
- cout << (stoi(strong) == sum ? "yes" : "no") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement