Skip to content

Instantly share code, notes, and snippets.

@mepcotterell
Created December 6, 2012 23:31
Show Gist options
  • Save mepcotterell/4229402 to your computer and use it in GitHub Desktop.
Save mepcotterell/4229402 to your computer and use it in GitHub Desktop.
Armstrong
public class Armstrong {
public static void main(String[] args) {
for (int a = 0; a < 9; a++) {
for (int b = 0; b < 9; b++) {
for (int c = 0; c < 9; c++) {
int n = a * 100 + b * 10 + c;
int a3 = a * a * a;
int b3 = b * b * b;
int c3 = c * c * c;
if (a3 + b3 + c3 == n) System.out.println(n);
} // for
} // for
} // for
} // main
} // Armstrong
object Armstrong extends App{
for (a <- 0 to 9; b <- 0 to 9; c <- 0 to 9) {
val n = a * 100 + b * 10 + c
val a3 = a * a * a
val b3 = b * b * b
val c3 = c * c * c
if (a3 + b3 + c3 == n) println(n)
} // for
} // Armstrong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment