Project Euler 043
March 26, 2023
#project-euler#algorithms#number-theory
Sub-string divisibility
First, try with all multiples of 17 that has different digits:
Since , and are known values, the next step is:
to calculate the value of :
More generally:
Since and are known values, is also known. To calculate is enough with a preprocessing for every prime number from to . Finally, the equation is similar to: , so for every digit the search space is reduced for just or values.
Time Complexity:
Just for and is needed to iterate from to and there are just numbers that met the requirements for .