armstrong number in java
int c=0,a,temp; int n=153;//It is the number to check armstrong temp=n; while(n>0) { a=n%10; n=n/10; c=c+(a*a*a); } if(temp==c) System.out.println("armstrong number"); else System.out.println("Not armstrong number");
armstrong number in java
int c=0,a,temp; int n=153;//It is the number to check armstrong temp=n; while(n>0) { a=n%10; n=n/10; c=c+(a*a*a); } if(temp==c) System.out.println("armstrong number"); else System.out.println("Not armstrong number");
armstrong number in java
import java.util.Scanner; public class Armstrong { public static void main(String args[]) { int num,temp,c=0; Scanner in=new Scanner(System.in); num=in.nextInt(); temp=num; while(num!=0) { int d=num%10; //extracting last digit c+=d*d*d; num/=10; // removing last digit } if(temp==c) { System.out.println("Number is Armstrong"); } else System.out.println("Number is not Armstrong"); } }
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us