Browse Source

unsuccessful in finding solution to PE 100 with integer square root idea...

master
Charles Reid 8 years ago
parent
commit
9c9064864d
  1. 38
      100/FindBlues.java

38
100/FindBlues.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
public class FindBlues {
public static void main(String[] args) {
findSolutions((long)(1E12));
}
/** Find solutions to the problem of
* how many blue records to have so that
* two blue records taken at random have
* 50% probability.
*/
public static void findSolutions(long originalN) {
long N = originalN;
int count = 0;
boolean done = false;
while(!done) {
N++;
count++;
long operand = 2*N*(N-1)+1;
long squirt = (long)(Math.sqrt(operand));
if(squirt*squirt == operand) {
if(squirt%2==1) {
System.out.println("Found solution.");
break;
}
}
}
long operand = 2*N*(N-1)+1;
long NB = (long)(Math.sqrt(operand));
System.out.println("N:\t"+N);
System.out.println("NB:\t"+NB);
// Nope....
}
}
Loading…
Cancel
Save