Project Euler 318 - 2011 nines
Project Euler 318 - 2011 nines
Official link: https://projecteuler.net/problem=318
Thought Process
Thought Process
Note: this problem is not suitable for hints! I suggest you read the linked stackexchange post and figure it out yourself before reading further!!
Fun problem that relies on a neat trick, learnt it from this post: https://math.stackexchange.com/questions/1536761/limit-with-fractional-part-lim-limits-n-to-infty-2-sqrt3n
We now have a condition to ensure that the fractional part of (sqrt(p) + sqrt(q))^(2n) goes to 1!
Therefore, we just need to sum ceiling(-2011/log(p + q - 2sqrt(pq))) for all p < q such that p + q ≤ 2011 and 0 < p + q - 2sqrt(pq) < 1
Interactive Code
Interactive Code
Input an integer (yourinput)
Code outputs ΣN(p, q) for p + q ≤ yourinput