public class Armstrong1to1000 { public static void main(String[] args) { System.out.println("Amstrong Numbers From 1 to 1000"); int a,r; for(int i=1; i<=1000;i++) { a=0; int n=i; while(n!=0) { r=n%10; a=a+r*r*r; n=n/10; } if(a==i) { System.out.println(i); } } } } OUTPUT: Amstrong Numbers From 1 to 1000 1 153 370 371 407
Basic Java programs. All programs done in very simple ways. It helps beginners to grow their programming skills and build a programming logic.
Friday, 11 December 2020
Armstrong numbers from 1 to 1000
Subscribe to:
Post Comments (Atom)
Good work sir.
ReplyDelete