simplifying ulam spiral code
- To: mathgroup at smc.vnet.net
- Subject: [mg56394] simplifying ulam spiral code
- From: zak <chocolatez at gmail.com>
- Date: Sat, 23 Apr 2005 01:16:49 -0400 (EDT)
- Reply-to: zak <chocolatez at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
hi in the site: http://teachers.crescentschool.org/weissworld/m3/spiral/spiral.html there is a mathematica code for drawing ULAM'S SPIRAL the code is: dat = Table[i, {i, 20000}]; x := 0; y := 0; num := 1; shift := 1; point := {x, y}; list = {} While[num <= 20000, i := 1; While[i <= shift, x = x + 1; If[PrimeQ[dat[[num]]] == True, list = Flatten[{list, point}]]; num++; i++;]; i := 1; While[i <= shift, y = y + 1; If[PrimeQ[dat[[num]]] == True, list = Flatten[{list, point}]]; num++; i++;]; shift++; i := 1; While[i <= shift, x = x - 1; If[PrimeQ[dat[[num]]] == True, list = Flatten[{list, point}]]; num++; i++;]; i := 1; While[i <= shift, y = y - 1; If[PrimeQ[dat[[num]]] == True, list = Flatten[{list, point}]]; num++; i++;]; shift++;] ListPlot[Partition[list, 2], PlotStyle -> PointSize[0.007], AspectRatio -> Automatic, Axes -> True]; or see text in: http://sr1.mytempdir.com/15902 Please i hope someone transform it to a functional programming code. thanks zak
- Follow-Ups:
- Re: simplifying ulam spiral code
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: simplifying ulam spiral code
- From: DrBob <drbob@bigfoot.com>
- Re: simplifying ulam spiral code
- From: DrBob <drbob@bigfoot.com>
- Re: simplifying ulam spiral code