← Complete problem index

PROJECT EULER · #0585

Nested Square Roots

Statement only · UnsolvedOriginal problem ↗

Consider the term x+y+z that is representing a nested square root. x, y and z are positive integers and y and z are not allowed to be perfect squares, so the number below the outer square root is irrational. Still it can be shown that for some combinations of x, y and z the given term can be simplified into a sum and/or difference of simple square roots of integers, actually denesting the square roots in the initial expression.

Here are some examples of this denesting:
3+2+2=2+1=2+1
8+15+15=5+3
20+96+12=9+6+32=3+6+32
28+160+108=15+6+52

As you can see the integers used in the denested expression may also be perfect squares resulting in further simplification.

Let F(n) be the number of different terms x+y+z, that can be denested into the sum and/or difference of a finite number of square roots, given the additional condition that 0<xn. That is,
x+y+z=i=1ksiai
with k, x, y, z and all ai being positive integers, all si=±1 and xn.
Furthermore y and z are not allowed to be perfect squares.

Nested roots with the same value are not considered different, for example 7+3+27, 7+12+12 and 7+27+3, that can all three be denested into 2+3, would only be counted once.

You are given that F(10)=17, F(15)=46, F(20)=86, F(30)=213 and F(100)=2918 and F(5000)=11134074.
Find F(5000000).

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.