Latest News :
Pin It

Widgets

To Check Strong Number

 
 
Definition of strong number:

A number is called strong number if sum of the factorial of its digit is equal to number itself. For example: 145 since
1! + 4! + 5! = 1 + 24 + 120 = 145
 
 
 
Code 1:
1. Write a c program to check whether a number is strong or not
#include<stdio.h>
int main(){
  int num,i,f,r,sum=0,temp;
  printf("Enter a number: ");
  scanf("%d",&num);
 
  temp=num;
  while(num){
      i=1,f=1;
      r=num%10;
      while(i<=r){
         f=f*i;
        i++;
      }
      sum=sum+f;
      num=num/10;
  }
  if(sum==temp)
      printf("%d is a strong number",temp);
  else
      printf("%d is not a strong number",temp);
  return 0;
}
Sample output:
Enter a number: 145
145 is a strong number
 
Code 2:
 
1. C program for strong number
2. Strong number program in c
#include<stdio.h>
int main(){
  int num,i,f,r,sum,temp;
  int min,max;
  printf("Enter minimum range: ");
  scanf("%d",&min);
  printf("Enter maximum range: ");
  scanf("%d",&max);
  printf("Strong numbers in given range are: ");
  for(num=min; num <= max; num++){
      temp = num;
      sum=0;
      while(temp){
           i=1;
           f=1;
           r=temp%10;
           while(i<=r){
             f=f*i;
             i++;
           }
         sum=sum+f;
         temp=temp/10;
      }
        
      if(sum==num)
           printf("%d ",num);
  }
  return 0;
}
Sample output:
Enter minimum range: 100
Enter maximum range: 100000
Strong numbers in given range are: 145 40585
Share this article :

+ comments + 1 comments

22 February 2020 at 15:51

Water Hack Burns 2 lb of Fat OVERNIGHT

Over 160k women and men are using a simple and secret "liquids hack" to drop 1-2 lbs each and every night in their sleep.

It's very easy and works on everybody.

Just follow these easy step:

1) Hold a drinking glass and fill it with water half the way

2) And now do this amazing hack

and become 1-2 lbs thinner when you wake up!

Post a Comment

 
Support : SandD Corporation | Sandy | StuffZone
Copyright © 2012. StuffZONE: Find Your Stuff - All Rights Reserved
Template Created by Sandy Published by SandD Corporation
Proudly powered by Me