Ulam spiral (for primes): Difference between revisions

no edit summary
imported>Maxima enthusiast
No edit summary
Line 3,326:
* * *
* * * * </pre>
 
=={{header|Maxima}}==
[[File:Ulam spiral.png|thumb|Ulam spiral powered by Maxima]]
Using the function defined in the Spiral matrix task
<syntaxhighlight lang="maxima">
/* Adapting the spiral to the problem requirements */
spiral_from_center(n):=(n^2+1)*matrixmap(lambda([x],x+1),zeromatrix(n,n))-spiral(n)$
 
/* Testing */
spiral_from_center(35)$
matrixmap(lambda([x],if primep(x) then "O" else ""),%);
</syntaxhighlight>
 
=={{header|Nim}}==