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: [mg87352] Re:[mg87308] need help
  • From: Patrick Klitzke <philologos14 at gmx.de>
  • Date: Tue, 8 Apr 2008 05:38:37 -0400 (EDT)

Hello,
1.) I think you need the function RandomChoice:
RandomChoice[Range[-100,100],20]

RandomChoice[list,n]

2.) I have written this little function for you:

Sumf4[x_] := (
  s = x; s1 = x;
  While[MatchQ[Sqrt[s1], _Integer] == False, s1--];
  s -= s1;
  s2 = s;
  While[MatchQ[Sqrt[s2], _Integer] == False, s2--];
  s -= s2;
  s3 = s;
  While[MatchQ[Sqrt[s3], _Integer] == False, s3--];
  s -= s3;
  s4 = s;
  While[MatchQ[Sqrt[s4], _Integer] == False, s4--];
  s -= s4;
  Print[Sqrt[s1]^"2", "+", Sqrt[s2]^"2", "+", Sqrt[s3]^"2", "+",
   Sqrt[s4]^"2", " Remainder=", s]
  )

If you want to have the 4 squares for 91 for example,
you have to type the following:
Sumf4[91]
9^(2)+3^(2)+1+0^(2) Remainder=0

But the problem is, that for some numbers you need more than 4 squares:
96=9^2+3^2+2^2+1^2+1^2

I think I will give you the solution to this problem in some days, when 
I have more time, if  then it has not been answered.
But first of all, think of a solution by yourself and post it. I am 
really interested.
I hope I could help you.

Best regards

Patrick Klitzke

email:philologos14 at gmx.de


  • Prev by Date: basic questions
  • Next by Date: question on player pro
  • Previous by thread: Re: need help
  • Next by thread: Re: Re:need help