[Tutor] Primes on a two-dimensional plane in the form of a rectangular spiral

Julieta julieta_rangel@hotmail.com
Sun, 8 Apr 2001 17:12:08 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C0C04F.0B0992A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

The primes, 2,3,4,5,7, . . . can be arranged on a two-dimensional plane =
in the form of a rectangular spiral.
<-represents left   -> represents right    ^represents up     | =
represents down

59 <-  53 <-  47  <-  43    <-    41
                                             ^
        11 <-   7    <-   5   <-     37
          |                    ^            ^
        13        2   ->   3           31
          |                                 ^=20
        17  ->  19  ->  23   ->    29

How could I write a program which inputs integers M and N and outputs =
the value of the number at location (M, N) on the plane?  The initial 2 =
is stored at position  (0,0).   This means that an input of ( 0, 0 ) =
should output 2.  An input of, say, ( -1, 1) should output 11; an input =
of (-1,2) should output 53, and so on.

I don't have any programming experience nor have I ever taken a computer =
programming class, however, I would like to start learning.  I've =
written very small programs (20 lines long) in my TI - 92 calculator and =
in Python, and I'm trying to build on that.  Right now I'm trying to =
learn some Python, so any kind of input on this problem would help =
tremendously.



------=_NextPart_000_0005_01C0C04F.0B0992A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The primes, 2,3,4,5,7, . . . can be =
arranged on a=20
two-dimensional plane in the form of a rectangular spiral.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;-represents left&nbsp;&nbsp; -&gt; =
represents=20
right&nbsp;&nbsp;&nbsp; ^represents up&nbsp;&nbsp;&nbsp;&nbsp; | =
represents=20
down</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>59 &lt;-&nbsp; 53 &lt;-&nbsp; 47  =
&lt;-&nbsp;=20
43&nbsp;&nbsp;&nbsp; &lt;-&nbsp;&nbsp;  41</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11=20
&lt;-&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp; &lt;-&nbsp;&nbsp;=20
5&nbsp;&nbsp;&nbsp;&lt;-&nbsp;&nbsp;&nbsp;&nbsp; 37</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
^&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
^</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  2&nbsp;&nbsp; -&gt;&nbsp;&nbsp;=20
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  31</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
 ^ </FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17&nbsp; =
-&gt;&nbsp;=20
19&nbsp; -&gt;&nbsp;&nbsp;23&nbsp;&nbsp; -&gt;&nbsp;&nbsp;&nbsp; =
29</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>How could I write a program which =
inputs integers M=20
and N and outputs the value of the number at location (M, N) on the =
plane?&nbsp;=20
The initial 2 is stored at position&nbsp; (0,0).&nbsp;&nbsp; This means =
that an=20
input of ( 0, 0 ) should output 2.&nbsp; </FONT><FONT face=3DArial =
size=3D2>An input=20
of, say, ( -1, 1) should output 11; an input of (-1,2) should output 53, =
and so=20
on.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I don't have any programming experience =
nor have I=20
ever taken a computer programming class, however, I would like to start=20
learning.&nbsp; I've written very small programs (20 lines long) in my =
TI - 92=20
calculator and in Python, and I'm trying to build on that.&nbsp; Right =
now I'm=20
trying to learn some Python, so any kind of input on this problem would =
help=20
tremendously.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0005_01C0C04F.0B0992A0--