Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: A small syntax error causing Kernel crash, Version 6.0.1
  • Next by Date: Frametick Orientation (2 Questions)
  • Previous by thread: Re: need help
  • Next by thread: RegionPlot color