Assignment #118 and Number Puzzles III: Armstrong Numbers
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Number Puzzles III: Armstrong Numbers
///File Name: Puzzle3.java
///Date Finished: 12/17/15
public class Puzzle3
{
public static void main ( String[] args )
{
int a;
double b;
for ( int h = 1; h < 10; h++)// h for hundreds
{
for ( int t = 0; t < 10; t++)
{
for ( int o = 0; o < 10; o++)
{
a = ( 100 * h ) + ( 10 * t ) + o;
b = Math.pow(h,3) + Math.pow(t,3) + Math.pow(o,3);
if ( a == b )
{
System.out.print(h);
System.out.print(t);
System.out.print(o + " ");
}
}
}
}
System.out.println();
}
}
Picture of the output