Advertisement
Realratnadwip

Strong Number Checker

Jun 29th, 2025 (edited)
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6.     int num, temp, rem, fact, i, sum;
  7.  
  8.     printf("This is a simple program to check Strong Number.\n\n");
  9.     printf("Enter a number : ");
  10.     scanf("%d", &num);
  11.  
  12.     temp = num;
  13.     sum = 0;
  14.  
  15.     while(temp != 0)
  16.     {
  17.         rem = temp % 10;
  18.         fact = 1;
  19.  
  20.         for(i = 1; i <= rem; i++)
  21.         {
  22.             fact = fact * i;
  23.         }
  24.  
  25.         sum = sum + fact;
  26.         temp = temp / 10;
  27.     }
  28.  
  29.     if(sum == num)
  30.     {
  31.         printf("%d - is a Strong Number.", num);
  32.     }
  33.     else
  34.     {
  35.         printf("%d - is not a Strong Number.", num);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement