Achilles numbers: Difference between revisions
→{{header|ALGOL 68}}
(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
# 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
# totient of the number is also
# 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
[ 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
BEGIN
print( ( "First 50
INT a count := 0;
FOR a WHILE a count < 50 DO
Line 128:
OD
END;
# show the first 50 Strong
BEGIN
print( ( "First 20 Strong
INT s count := 0;
FOR s WHILE s count < 20 DO
Line 144:
OD
END;
# count the number of
BEGIN
INT a count := 0;
Line 151:
FOR a TO UPB achiles DO
IF achiles[ a ] THEN
# have an
a count +:= 1
FI;
IF a = power of 10 THEN
# have reached a power of 10 #
print( ( "
, " digits: ", whole( a count, -6 )
, newline
Line 169:
END</lang>
{{out}}
▲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
500 864 1944 2000 2592 3456 5000 10125 10368 12348
12500 16875 19652 19773 30375 31104 32000 33275 37044 40500
=={{header|C++}}==
|