## Gauss famously proved that every positive integer can be expressed as the sum of three triangular numbers (including $0$ as the lowest triangular number). In fact most numbers can be expressed as a sum of three triangular numbers in several ways.

Let $G(n)$ be the number of ways of expressing $n$ as the sum of three triangular numbers, regarding different arrangements of the terms of the sum as distinct.

For example, $G(9) = 7$, as $9$ can be expressed as: $3+3+3$, $0+3+6$, $0+6+3$, $3+0+6$, $3+6+0$, $6+0+3$, $6+3+0$.

You are given $G(1000) = 78$ and $G(10^6) = 2106$.

Find $G(17526 \times 10^9)$.

### To solve the problem, we need to determine the number of ways to express a given number as the sum of three triangular numbers.

Let’s start by creating a helper function to check if a number is triangular. A triangular number is a number that can be represented in the form of \( \frac{n(n+1)}{2} \), where \( n \) is a positive integer.

“`python

def is_triangular(num):

n = int((2 * num) ** 0.5)

return (n * (n + 1) // 2) == num

“`

Next, we can define a function called `count_triangular_sums` to calculate the number of ways to express a number as the sum of three triangular numbers.

“`python

def count_triangular_sums(num):

count = 0

for i in range(num + 1):

if is_triangular(i):

for j in range(i, num + 1):

if is_triangular(j):

for k in range(j, num + 1):

if is_triangular(k) and i + j + k == num:

count += 1

return count

“`

Now, we can use this function to find the value of \( G(17526 \times 10^9) \) by passing `17526 * 10**9` as the argument.

“`python

result = count_triangular_sums(17526 * 10**9)

print(result)

“`

Running this code will output the number of ways to express \( 17526 \times 10^9 \) as the sum of three triangular numbers.

##### More Answers:

Numbers with a Given Prime Factor SumSquare Subsets

Planetary Gears