Achilles numbers: Difference between revisions
Content deleted Content added
J: simplification |
J: add some comments |
||
Line 76:
+/achilles (+i.)/1 9*10^<:6
664</lang>
Explanation of the code:
<tt>(1{__&q:)</tt> is a function which returns the non-zero power of the prime factors of a positive integer. (__&q: returns both the primes and their factors, but here we do not care about the primes themselves.)
<tt>+./</tt> returns the greatest common divisor of a list, and 1=+./ is true if that gcd is 1 (0 if it's false).
<tt>*/ .>&1</tt> is true if all the values in a list are greater than 1 (0 if not).
<tt>"0</tt> maps a function onto the individual (rank 0) items of a list or array (we use this to avoid complexities: for example if we padded our lists of prime factor powers with zeros, we could still find the gcd, but our test that the powers are greater than 1 would fail).
<tt>5&p:</tt> is euler's totient function.
<tt>(#~ predicate) list</tt> selects the elements of <tt>list</tt> where <tt>predicate</tt> is true.
=={{header|Raku}}==
|