Re:need help
- To: mathgroup at smc.vnet.net
- Subject: [mg87381] Re:[mg87308] need help
- From: Patrick Klitzke <philologos14 at gmx.de>
- Date: Wed, 9 Apr 2008 05:54:22 -0400 (EDT)
Here is my solution for the function for any number of squares. Sumf[x_] := ( data = {}; s = x; s1 = x; i = 0; While[ s != 0, { s1 = s; While[MatchQ[Sqrt[s1], _Integer] == False, s1--]; i++; If[s1 == 1, AppendTo[data, "1"^"2"], AppendTo[data, Sqrt[s1]^"2"]]; s -= s1; } ]; Row[data, "+"] ) Thank you for posting your problem. By solving this problem I learned a lot of about how mathematica works. Best regards, Patrick Klitzke email: philologos14 at gmx.de