Magic numbers: Difference between revisions

→‎{{header|ALGOL 68}}: Avoid counting the single digit magic numbers twice
m (→‎{{header|ALGOL 68}}: total count is off)
(→‎{{header|ALGOL 68}}: Avoid counting the single digit magic numbers twice)
Line 36:
 
=={{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}}
Uses Algol 68G's LONG LONG INT, which has programmer definable precissionprecision, the default is sufficient for this task.
<syntaxhighlight lang="algol68">
BEGIN # count magic numbers: numbers divisible by the count of digits and #
Line 78 ⟶ 77:
# find the magic numbers #
print( ( "Magic number counts by number of digits:", newline ) );
INT m count := 100; # total number of magic numbers #
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 : 0 ]LONG LONG INT magic9;
Line 146 ⟶ 145:
24: 3
25: 1
Total: 2046720457 magic numbers
Largest is 3608528850368400786036725
Minimally pandigital 1-9 magic numbers: 381654729
3,032

edits