From 9c9064864d2e2124ac2f0ef0f260ccd6764e1382 Mon Sep 17 00:00:00 2001 From: Charles Reid <charlesreid1@gmail.com> Date: Wed, 5 Jul 2017 02:04:37 -0700 Subject: [PATCH] unsuccessful in finding solution to PE 100 with integer square root idea... --- 100/FindBlues.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 100/FindBlues.java diff --git a/100/FindBlues.java b/100/FindBlues.java new file mode 100644 index 0000000..3dfbd39 --- /dev/null +++ b/100/FindBlues.java @@ -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.... + + } + +} +