Skip to main content
5 of 7
added 9 characters in body
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

An easy way, using PowersRepresentations[]:

$PowersRepresentations[n,k,p] $ gives the distinct representations of the integer n as a sum of k non-negative p^th integer powers.

s1 = Join@@ (Select[PowersRepresentations[748,#,2], Intersection[#, Range@16] == # &] & /@ Range@8)

Gives all possible ways to total 748.

For filtering the ones that are complementary:

s = Tally[s1, Union[#1, #2] == Range@16 &][[All, 1]];
Length@s
(*
 57
*)
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456