Skip to content

Instantly share code, notes, and snippets.

@suryansh011
Last active February 19, 2023 19:06
Show Gist options
  • Save suryansh011/b99552fa707e9331aa983b3c411d048f to your computer and use it in GitHub Desktop.
Save suryansh011/b99552fa707e9331aa983b3c411d048f to your computer and use it in GitHub Desktop.
/*
*
* Title: Finding the Armstrong Number
* By: Suryansh Singh Shishodia
* Github: https://github.com/elekktron
*
*/
#include <stdio.h>
#include <math.h>
int main() {
int num,temp,digit,armstrong,x,y=0;
printf("Enter the number to find the Armstrong Numbers upto: ");
scanf("%d",&num);
printf("The following numbers upto %d are the Armstrong numbers:\n",num);
temp = num;
if (num==0)
x = 1;
//Finding the armstrong number
while(y != num){
armstrong = 0;
x=0;
y++;
temp = y;
//Calculating number of digits
while (temp!=0){
temp = temp/10;
x++;
}
temp = y;
while(temp != 0){
digit = temp%10;
armstrong = armstrong + pow(digit,x);
temp = temp/10;
}
if(y == armstrong) {
printf("%d\n",armstrong);
}
}
return 0;
}
@mochiron-desu
Copy link

Yo I want to connect with you... Do you by any chance go by the name Hercules earlier? Also Pokemon perhaps?? I want to tell you something that you might wanna know !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment