Achilles numbers: Difference between revisions

(Achilles numbers in FreeBASIC)
Line 51:
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find AchilesAchilles Numbers: numbers whose prime factors p appear at least #
# twice (i.e. if p is a prime factor, so is p^2) and cannot be #
# expressed as m^k for any integer m, k > 1 #
# also find strong AchilesAchilles Numbers: Achiles Numbers where the Euler's #
# totient of the number is also Achiles Achilles #
# returns the number of integers k where 1 <= k <= n that are mutually #
# prime to n #
Line 82:
PR read "primes.incl.a68" PR # include prime utilities #
[]BOOL prime = PRIMESIEVE max number; # construct a sieve of primes #
# table of numbers, will be set to TRUE for the AchilesAchilles Numbers #
[ 1 : max number ]BOOL achiles;
FOR a TO UPB achiles DO
Line 114:
OD;
# achiles now has TRUE for imperfect powerful numbers #
# show the first 50 AchilesAchilles Numbers #
BEGIN
print( ( "First 50 AchilesAchilles Numbers:", newline ) );
INT a count := 0;
FOR a WHILE a count < 50 DO
Line 128:
OD
END;
# show the first 50 Strong AchilesAchilles numbers #
BEGIN
print( ( "First 20 Strong AchilesAchilles Numbers:", newline ) );
INT s count := 0;
FOR s WHILE s count < 20 DO
Line 144:
OD
END;
# count the number of AchilesAchilles Numbers by their digit counts #
BEGIN
INT a count := 0;
Line 151:
FOR a TO UPB achiles DO
IF achiles[ a ] THEN
# have an AchilesAchilles Number #
a count +:= 1
FI;
IF a = power of 10 THEN
# have reached a power of 10 #
print( ( "AchilesAchilles Numbers with ", whole( digit count, 0 )
, " digits: ", whole( a count, -6 )
, newline
Line 169:
END</lang>
{{out}}
<pre>First 50 AchilesAchilles Numbers:
<pre>
First 50 Achiles Numbers:
72 108 200 288 392 432 500 648 675 800
864 968 972 1125 1152 1323 1352 1372 1568 1800
Line 176 ⟶ 175:
3528 3872 3888 4000 4232 4500 4563 4608 5000 5292
5324 5400 5408 5488 6075 6125 6272 6728 6912 7200
First 20 Strong AchilesAchilles Numbers:
500 864 1944 2000 2592 3456 5000 10125 10368 12348
12500 16875 19652 19773 30375 31104 32000 33275 37044 40500
AchilesAchilles Numbers with 2 digits: 1
AchilesAchilles Numbers with 3 digits: 12
AchilesAchilles Numbers with 4 digits: 47
AchilesAchilles Numbers with 5 digits: 192
AchilesAchilles Numbers with 6 digits: 664</pre>
</pre>
 
=={{header|C++}}==
1,111

edits