mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
Delete disarium.c
This commit is contained in:
parent
c6103845c2
commit
2602295418
31
disarium.c
31
disarium.c
@ -1,31 +0,0 @@
|
|||||||
// a disarium number is a number such that sum of the digits of the number raised to their respective position equals the number
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int n,i=0,j,sum=0,l,k;
|
|
||||||
scanf("%d",&n);
|
|
||||||
k=n; //number stored in temporary variable
|
|
||||||
j=k;
|
|
||||||
while(n>0)
|
|
||||||
{
|
|
||||||
d=n%10;
|
|
||||||
n=n/10;
|
|
||||||
i++; //to get the number of digits which will be the position for last digit
|
|
||||||
}
|
|
||||||
while(k>0)
|
|
||||||
{
|
|
||||||
l=k%10; //to get the digit
|
|
||||||
sum=sum+pow(l,i);
|
|
||||||
k=k/10;
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
if(j==sum)
|
|
||||||
{
|
|
||||||
printf("It is an disarium number");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("It is not disarium number");
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user