Ulam spiral (for primes): Difference between revisions
m
→using FreePascal
Line 3,408:
CONST
(*)
SIZE = 9 ;▼
Only odd numbers work
(*)
▲ SIZE = 9 ;
MSIZE = SIZE * ord ( Odd ( SIZE ) ) ;
TYPE
Line 3,435 ⟶ 3,439:
VAR
j: integer;
mid: integer =
BEGIN
FOR j:= 1 to
BEGIN
Arr [ mid - j ] [ mid - j ] := '.' ;
Line 3,468 ⟶ 3,474:
cnt: integer = 1 ;
Turn_cnt: integer = 0 ;
x: integer =
y: integer =
BEGIN
WHILE ( cnt <
BEGIN
Line 3,518 ⟶ 3,524:
VAR
Arr: D2Arr ;
BEGIN
WriteLn ( 'Only odd numbers work for SIZE' ) ;
Add2DArr ( Arr ) ;▼
SetLength ( Arr, MSIZE, MSIZE ) ;
Init2DArr ( Arr ) ;
▲ Add2DArr ( Arr ) ;
Show2DArr ( Arr , False ) ;
Show2DArr ( Arr , True ) ;
END.
</lang>JPD 2021/06/14
Output:
61 59
37 31
67 17 13
5 3 29
19 2 11 53
41 7
71 23
43 47
73 79
′ ′
′ ′
′ ′ ′
′ ′ ′
′ ′′ ′
′ ′
′ ′
′ ′
′ ′
=={{header|Perl}}==
|