#include<iostream>
      using namespace std;
      // function to calculate factorial
      int facto(int n){
          int fact = 1;
          for(int i = 1; i <= n; i++)
                  fact = fact * i;
          return fact;
      }
      int detectStrong(int num){
          int digit, sum = 0;
          int temp = num;
          // calculate 1! + 4! + 5!
          while(temp!=0){
              digit = temp % 10;
              sum = sum + facto(digit);
              temp /= 10;
          }
          // returns 1 if both equal else 0
          return sum == num;
      }
      int main ()
      {
          int num = 145;
          if(detectStrong(num))
              cout << num << " is Strong Number";
          else
              cout << num << " is Not Strong Number";
      }
      
      Dart language logo

      Check if a Number

      0

      0

      avatar
      Ayush Gupta

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.