C program to display the strong numbers between a given range

Write a C program to display (print) the strong numbers between a given range

Strong number is an Integer Number.  If the sum of factorial of all digits of the number is equal to the given number, then the given number is called Strong number. Example of Strong Number : 145 (That is, 1! + 4! + 5! = 1+24+120 = 145). The below given C program to display (print) the strong numbers between a given range. Kindly check out the program to display the strong numbers between a given range.


C Program to display (print) the strong numbers :


#include<stdio.h>

int main(){

  int numbr,k,fact,rem,sum=0,input;

  int first,last;

  printf("Enter the first value: ");

  scanf("%d",&first);

  printf("Enter the last value: ");

  scanf("%d",&last);

  printf("The Strong numbers in the given range are: ");

  for(numbr=first; numbr <= last; numbr++){

      input = numbr;

      sum=0;

      while(input>0){

          k=1;

           fact=1;

           rem=input%10;

           while(k<=rem){

             fact=fact*k;

             k++;

           }

         sum=sum+fact;

         input=input/10;

      }

      if(sum==numbr)

           printf("%d ",numbr);

  }

  return 0;

}

 


Sample output:

Enter the first value: 100

Enter the last value: 10000

The Strong numbers in the given range are: 145


Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share