# Task
`Triangular numbers` are defined by the formula `n * (n + 1) / 2` with `n` starting from 1. They count the number of objects that can form an equilateral triangle as shown in the picture below:

![](https://i.gyazo.com/eec11cc9e17a31324338edc4eb7bb746.png)

So the sequence of triangular numbers begins as follows:

`1, 3, 6, 10, 15, 21, 28, ....`

It is proven that the sum of squares of any two consecutive triangular numbers is equal to another triangular number.

You're given a triangular number `n`. Return `true` if it can be represented as `a sum of squares of two consecutive triangular numbers`, or `false` otherwise.


# Input/Output

`[input]` integer `n`

A positive triangular number

`3 ≤ n ≤ 10^9`

`[output]` a boolean value

`true` if it is possible to represent n as the sum of squares of two consecutive triangular numbers, and `false` otherwise.

# Example

For `n = 6`, the output should be `false`.

No two squared consecutive triangular numbers add up to 6.

For `n = 45`, the output should be `true`.

`3 * 3 + 6 * 6 = 9 + 36 = 45`

Difficulty: introductory

Starter code:

def triangular_sum(n):
	

Solutions:
triangular_sum=lambda n: (-0.5+(1+8*n)**0.5/2.0)**0.5%1==0

from math import sqrt

def triangular_sum(n):
    return sqrt(2 * (sqrt(8*n + 1) - 1)) % 2 == 0

def triangular_sum(n):
    r = int((n*2)**0.5)
    return r * (r+1) / 2 == n and round(r**0.5)**2 == r

triangular_sum = lambda n: ((((1+8*n)**0.5 - 1) / 2)**0.5).is_integer()

def triangular_sum(n):
    return ((2*n+.25)**.5-.5)**.5 % 1 == 0

triangular_sum=lambda n:not((32*n+4)**.5-2)**.5%1

t = [n * (n + 1) // 2 for n in range(2, 32000)]
memo = {a ** 2 + b ** 2 for a, b in zip(t, t[1:])}

def triangular_sum(n):
    return n in memo

a = [i*(i+1)//2 for i in range(211)]
b = [i**2+j**2 for i,j in zip(a,a[1:])]

def triangular_sum(n):
    return n in b

def triangular_sum(n):
    return ((((1 + 8*n)**0.5 - 1) / 2)**0.5).is_integer()

def triangular_sum(t):
    triangles = [1]
    n = 2
    while triangles[-1] < t**0.5:
        triangles.append(triangles[-1] + n)
        n += 1
    for n1 in triangles:
        for n2 in triangles:
            if n1 != n2 and n1*n1 + n2*n2 == t:
                return True
    return False