Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Create P0003.java

  • Loading branch information...
David Lorenzo
David Lorenzo committed Oct 18, 2018
1 parent 9e2b711 commit 7dfc5a883db226c7c7809b2448dd476dc469edbc
Showing with 28 additions and 0 deletions.
  1. +28 −0 ProjectEuler/Java/P0003.java
@@ -0,0 +1,28 @@
/*
https://projecteuler.net/problem=3
Largest prime factor
Problem 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*/
public class P0003 {

public static boolean isPrime(int n) {
for (int i=2; i<n; i++) {
if (n%i == 0) {
return false;
}
}
return true;
}

public static void main(String[] args) {
for (int i=1; i<100; i++) {
if (isPrime(i)) {
System.out.println(i);
}
}

}

}

0 comments on commit 7dfc5a8

Please sign in to comment.
You can’t perform that action at this time.