My Solution of 100th Problem of Project Euler(Arranged Probability)

Revision en1, by Heisenberg_480, 2024-12-10 12:15:36

After reducing the problem to x*(x-1)/n*(n-1)=1/2, we can observe the first few values of n and x for which this equation is satisfied using a simple C++ program.We get first few values of n as 1,64,21,120,697 etc if we observe the difference of these numbers they are 3,17,99,577,...etc which is nothing but 2^2-1,4^2+1,10^2-1,24^2+1,... then we see that 2,4,10,24 follow a pattern and term t(i) of this series is t(i-1)*2+t(i-2).We can simply write a dp and keep adding the differences to a variable to keep track of value of n we have reached.Whenever our sum reaches over a 1e12,we break the loop.This is the first value of n over 1e12 to satisfy the equation.We then simple substitute x in original equation and solve the quadratic for x.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Heisenberg_480 2024-12-10 12:30:43 3
en1 English Heisenberg_480 2024-12-10 12:15:36 811 Initial revision (published)