We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Problem can be solved using quadratic congruence solver. We can check for prime p which values greater than p such n^2 + a are divisible by prime p. In this way we greatly reduce search space by obtaining exluded values for given number % prime. Primes up to 97 is sufficient.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #146: Investigating a Prime Pattern
You are viewing a single comment's thread. Return to all comments →
Problem can be solved using quadratic congruence solver. We can check for prime p which values greater than p such n^2 + a are divisible by prime p. In this way we greatly reduce search space by obtaining exluded values for given number % prime. Primes up to 97 is sufficient.