Cody

Problem 44334. Sums of Multiple Pairs of Triangular Numbers

Created by James in Community

This is a follow-up to Problem 44289 - Find two triangular numbers whose sum is input.

There are some numbers that are the sum of multiple pairs of triangular numbers. For example, 81 = 36+45 = 15+66 = 3+78. Given a number X, find all of the possible pairs of triangular numbers that add up to X. Your answer should be in a 2-by-X matrix. Each column of the matrix should sum to X, and each pair of triangular numbers should only appear once. The top row sorted from low to high. The output for 81 would be:

 [ 3   15  36 
  78   66  45]

Good luck!

Solution Stats

45.92% Correct | 54.08% Incorrect
Last solution submitted on Mar 08, 2019

Problem Comments

Solution Comments

Recent Solvers163

Suggested Problems

More from this Author80

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!