Totient function: Difference between revisions
Content added Content deleted
(Undo revision 335807 by Tigerofdarkness (talk)) |
Not a robot (talk | contribs) (Add APL) |
||
Line 212: | Line 212: | ||
Number of primes up to 90000 = 8713 |
Number of primes up to 90000 = 8713 |
||
Number of primes up to 100000 = 9592</pre> |
Number of primes up to 100000 = 9592</pre> |
||
=={{header|APL}}== |
|||
{{works with|Dyalog APL}} |
|||
<lang APL>task←{ |
|||
totient ← 1+.=⍳∨⊢ |
|||
prime ← totient=-∘1 |
|||
⎕←'Index' 'Totient' 'Prime',(⊢⍪totient¨,[÷2]prime¨)⍳25 |
|||
{⎕←'There are' (+/prime¨⍳⍵) 'primes below' ⍵}¨100 1000 10000 |
|||
}</lang> |
|||
{{out}} |
|||
<pre> Index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|||
Totient 1 1 2 2 4 2 6 4 6 4 10 4 12 6 8 8 16 6 18 8 12 10 22 8 20 |
|||
Prime 0 1 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 0 |
|||
There are 25 primes below 100 |
|||
There are 168 primes below 1000 |
|||
There are 1229 primes below 10000</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |