2

Link: https://projecteuler.net/problem=864

For short, you are asked to calculate: $\sum\limits_{i=1}^C \mu^2(i^2+1)$, where $\mu$ is the Mobius function and $C=123567101113$ is a large integer constant.

My attempts: For each prime $p$ of type $4k+1$, there exists two $n$ such that $n^2+1 \equiv 0\pmod{p}$. By Hensel lifting, there exists two $n$ such that $n^2+1 \equiv 0\pmod{p^2}$.

By CRT, for $p_1, p_2, ..., p_m$ of type $4k+1$, there exists $2^m$ choices of $n$ ($n \leq p_1^2p_2^2...p_m^2$) such that $n^2+1 \equiv 0 \pmod{ p_1^2p_2^2...p_m^2}$.

So by the principle of inclusion-exclusion (PIE), the solution looks like:

$$\sum\limits_{\substack{d \mid n,\\ d \text{ contains only} \\ \text{prime factors of }4k+1}} \mu(d)\left\lfloor \frac{n}{d^2} \right\rfloor 2^{w(d)}\label{1}\tag{1}$$

where $w(d)$ is the number of prime factors of $d$. However, Eq. \eqref{1} is not accurate because of the round up: For example, $n=7$ and $d=5$, $7^2+1 = 50$ contains a prime factor $5$. Generally speaking I don't know how many $n \leq (C \mod d)$ such that $n^2+1 \equiv 0\,(\mod d)$.

Also, Pell equations $x^2 - kd^2 = -1$ are considered, but no progress as well.

It is worth mentioning that a similar problem (Project Euler 399, Constrained square-free numbers) is based on Wall's conjecture (not proved yet), thus undetermined.

I have investigated into serval materials, e.g., D. R. Heath-Brown's paper "Square-free values of $n^2+1$", and a StackExchange post. Anyway, these materials are valuable, but they are theoretic rather than algorithmic. To be honest, due to limited knowledge on number theory, I don't dive deep. Also, I don't know whether they are helpful for this problem. I try to do brute force on two computers (Intel I7/Mac) with the sympy.factorint() API, but it becomes rather slow when $i$ comes to $\sim 1e7$.

============ Updated: I have solved it. The answer is 11057293xxxx, if you are interested, please contact me privately.

Muses_China
  • 1,008
  • 1
    From the problems I have seen on Project Euler, they seem to almost always require a computer to calculate them. – Kamal Saleh Dec 01 '23 at 15:12
  • @KamalSaleh What about the complexity? Usually a normal CPU deals about $1e8$ operations per second, but in this problem $C$ is up to $\sim ~1e11$. From the number of solutions, it is a hard problem. – Muses_China Dec 01 '23 at 15:15
  • There is usually some clever way to change it from impossible to hard. Factoring 10^11 very large numbers isn’t going to work. – gnasher729 Dec 01 '23 at 18:30
  • 7
    Note that public discussion of ProjectEuler problems, unless in a designated thread on PE for those who solved the problem, is highly discouraged by PE rules. – Oleksandr Kulkov Dec 01 '23 at 18:41
  • 7
    I’m voting to close this question because it is an active contest question – heropup Dec 01 '23 at 19:09
  • Your approach looks promising. There should be some method to bound $p$ that $n^2+1 \equiv 0\pmod{p^2}$. If you get, say $p\le n^{1/2}$, Then it should be feasible to consider all those primes. – Peter Wu Dec 05 '23 at 09:10
  • The set of squarefree numbers is a super set of Primes @PeterWu – menjaraz Dec 05 '23 at 18:08
  • @menjaraz did you read the inclusion-exclusion part? – Peter Wu Dec 06 '23 at 00:58
  • @PeterWu Yeap, I am considering some balancing like sqrt balancing. When $p$ is small, use the original method. When $p$ is large, use the Pell equation. – Muses_China Dec 06 '23 at 16:35
  • @Muses_China You should be pilotInPyjamas2 on Project Euler... Am I right? – menjaraz Jul 13 '24 at 14:31
  • @menjaraz Sorry, i am not – Muses_China Jul 23 '24 at 13:51

1 Answers1

-4

I looked at the problem, and there’s a trivial observation that $x^2+1$ is not divisible by 4 or 3, but divisible by 25 when x = 25k +/- 7. That accounts for 80 of the 105 non-square free numbers up to 1000^2+1.

I’d try to find out why that is (because (25a+b)^2+1 = 625a^2 + 50ab + b^2+1 is divisible by 25 when b=7), and if there is a way to find similar equations fast.

gnasher729
  • 10,611
  • 20
  • 38