Skip to content

Commit

Permalink
It's done, but need tricky solution to be faster.
Browse files Browse the repository at this point in the history
  • Loading branch information
abolfazl-sh committed Jul 17, 2020
1 parent 3b5693b commit 28789c0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Binary file added Java/Third.class
Binary file not shown.
37 changes: 37 additions & 0 deletions Java/Third.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class Third{

public static void main(String[] args){
long val = 600851475143L;
long result = 1L;
long counter = 1L;
do{
if(isPrime(counter)){
if(val % counter == 0){
result = counter;
System.out.println(result);
}
}

counter++;

}while(counter < val);
System.out.println(result);

}

public static boolean isPrime(long number){
if(number <= 1){
return false;
}
boolean isprime = true;
for(int i = 2; i < number; i++){
if(number % i == 0){
isprime = false;
break;
}

}
return isprime;
}

}

0 comments on commit 28789c0

Please sign in to comment.