Project Euler 601 - Divisibility Streaks
Official link: https://projecteuler.net/problem=601
Thought Process
I started by brute forcing the first 1,000 values and a very clear pattern can be seen (And it continued for first 10,000)
P(1,10^3) = 499 = floor(998/1) - floor(998/lcm(1,2))
P(2,10^3) = 333 = floor(998/lcm(1,2)) - floor(998/lcm(1,2,3))
P(3,10^3) = 83 = floor(998/lcm(1,2,3)) - floor(998/lcm(1,2,3,4))
P(4,10^3) = 67 = floor(998/lcm(1,2,3,4)) - floor(998/lcm(1,2,3,4,5))
P(5,10^3) = 0 = floor(998/lcm(1,2,3,4,5)) - floor(998/lcm(1,2,3,4,5,6))
Once I realised this, all that was left was to prove it was true, and it is quite clear using the Chinese Remainder Theorem
From this I can deduce that P(a,b) = floor((b-2)/lcm(1,2,...,a)) - floor((b-2)/lcm(1,2,...,a,a+1))
I added an LCM function to my Essential Functions page
Interactive Code
Input an integer (yourinput)
Code will output the sum from i = 1 to yourinput of P(i, 4^i)