C Program to check a number is a strong number or not


In this program, You will learn how to check a number is a strong number or not in c.


Some list of strong numbers is : 1, 2, 145

Example: How to check a number is a strong number or not in c

#include<stdio.h>
int main() {

  int n, t, r, i, f, s = 0;

  printf("Enter a number :");
  scanf("%d", &n);

  t = n;
  while (n > 0) {
    f = 1;
    r = n % 10;
    for (i = 1; i <= r; i++) {
      f = f * i;
    }
    s = s + f;
    n = n / 10;
  }

  if (s == t) {
    printf("It is a strong number :%d", t);
  } else {
    printf("It is not a strong number :%d", t);
  }

  return 0;
}

Output:

Enter a number :145
It is a strong number :145