I think it could have been designed with more object orientation. I don't like how one of my methods calls another from within the method, but I wasn't sure how to return the result because it is a loop.
Also is it ok to have all methods static, or should I be instantiating the classes?
If there is any other improvements please let me know, but these were my main concerns.
App.java:
public class App {
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
Fibonacci.fibonacci();
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println("****************************************\n");
System.out.println("Total Running Time: " + totalTime + "ms");
}
}
Fibonacci.class:
public class Fibonacci {
static void fibonacci() {
long i = 0;
long j = 1;
long k = 0;
while (i < 1E17) {
k = i + j;
i = j;
j = k;
Prime.prime(k);
}
}
}
Primes.java:
public class Prime {
static void prime(long number) {
boolean isPrime = false;
long end = (long) (Math.sqrt(number) + 1);
for (long i = 2; i <= end; i++) {
if (number % i == 0) {
isPrime = false;
break;
} else {
isPrime = true;
}
}
if (isPrime) {
System.out.println(number);
}
}
}