Created
August 9, 2022 16:41
-
-
Save SiddharthManthan/b8ca506b5e071c88f7a56ddf2391f0d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ArmStrongNumber { | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int n=sc.nextInt(); | |
int result=0; | |
int sum=0; | |
int num=0; | |
int cube=0; | |
int temp=0; | |
temp=n; | |
while(temp>0) { | |
num=temp%10; | |
cube=num*num*num; | |
sum=sum+cube; | |
temp=temp/10; | |
} | |
if(sum==n) { | |
result=1; | |
} | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment