Magic numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|ALGOL 68}}: total count is off)
(→‎{{header|ALGOL 68}}: Avoid counting the single digit magic numbers twice)
Line 36: Line 36:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{improve|ALGOL 68|There is only 20457 magic numbers, not 20467}}
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
Uses Algol 68G's LONG LONG INT, which has programmer definable precission, the default is sufficient for this task.
Uses Algol 68G's LONG LONG INT, which has programmer definable precision, the default is sufficient for this task.
<syntaxhighlight lang="algol68">
<syntaxhighlight lang="algol68">
BEGIN # count magic numbers: numbers divisible by the count of digits and #
BEGIN # count magic numbers: numbers divisible by the count of digits and #
Line 78: Line 77:
# find the magic numbers #
# find the magic numbers #
print( ( "Magic number counts by number of digits:", newline ) );
print( ( "Magic number counts by number of digits:", newline ) );
INT m count := 10; # total number of magic numbers #
INT m count := 0; # total number of magic numbers #
INT d count := 1; # number of digits #
INT d count := 1; # number of digits #
FLEX[ 1 : 10 ]LONG LONG INT magic := ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 );
FLEX[ 1 : 10 ]LONG LONG INT magic := ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 );
FLEX[ 1 : 0 ]LONG LONG INT magic9;
FLEX[ 1 : 0 ]LONG LONG INT magic9;
Line 146: Line 145:
24: 3
24: 3
25: 1
25: 1
Total: 20467 magic numbers
Total: 20457 magic numbers
Largest is 3608528850368400786036725
Largest is 3608528850368400786036725
Minimally pandigital 1-9 magic numbers: 381654729
Minimally pandigital 1-9 magic numbers: 381654729