Skip to content

Update ArmstrongNumber.java#1

Open
Albertxavier03 wants to merge 1 commit intoTestLeafPages:masterfrom
Albertxavier03:patch-1
Open

Update ArmstrongNumber.java#1
Albertxavier03 wants to merge 1 commit intoTestLeafPages:masterfrom
Albertxavier03:patch-1

Conversation

@Albertxavier03
Copy link

No description provided.

@Indhra10
Copy link

Indhra10 commented Sep 7, 2021

package week1.day2;

public class ArmstrongNumberex {

public static void main(String[] args) {
	// TODO Auto-generated method stub

//Armstrong number ex: n=134, amstrong number =(111)+(333)+(444)
int num=134;
int quo=0, rem=0, ans=0;

	while (num!=0) {
		quo=num/10;
		System.out.println(quo);
		rem=num%10;
		System.out.println(rem);
		 
		ans=ans+(rem*rem*rem);
		System.out.println(ans);
		
		num=quo;
		
	}
	System.out.println("The armstrong number is " + ans);
}

}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants