www.bullraider.com

Armstrong between 0 to 9999

AddThis Social Bookmark Button

Objective: Find out the numbers which are armstrong between 1 to 9999. What is armstrong see here


/*
 * Checking if a number is armstrong number
 */
public class ArmstrongBetween0To9999 {

	public static void main(String aga[]){
		int num;
		boolean isAmstrong=false;
		int result=0;
		int rem=0;
		for(int i=1;i<=9999;i++){
			num=i;
			while(num>=1){
				rem=num%10;
				result=(rem*rem*rem)+result;
				num=num/10;
			}
			if(result==i){
				System.out.println(i+" is an armstrong number");
			}
			result=0;
			rem=0;
		}
	}
}

 


Powered by Bullraider.com