forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFermat.java
More file actions
28 lines (24 loc) · 788 Bytes
/
Copy pathFermat.java
File metadata and controls
28 lines (24 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Fermat {
public static void main(String[] args) {
int a;
int b;
int c;
int n;
Scanner in = new Scanner(System.in);
System.out.print("What's your 'a' number? ");
a = in.nextInt();
System.out.print("What's your 'b' number? ");
b = in.nextInt();
System.out.print("What's your 'c' number? ");
c = in.nextInt();
System.out.print("What's your 'n' number? ");
n = in.nextInt();
boolean result = Math.pow(a, n) + Math.pow(b, n) == Math.pow(c, n);
if (n > 2 && result) {
System.out.println("Holy smokes, Fermat was wrong!");
} else {
System.out.println("No, that doesn't work.");
}
}
}