RosettaCodeData/Task/Totient-function/00-TASK.txt

46 lines
2.1 KiB
Plaintext

The   '''totient'''   function is also known as:
::*   Euler's totient function
::*   Euler's phi totient function
::*   phi totient function
::* &nbsp; <big> Φ </big> &nbsp; function &nbsp; (uppercase Greek phi)
::* &nbsp; <big> &phi;&nbsp; </big> &nbsp; function &nbsp; (lowercase Greek phi)
;Definitions &nbsp; (as per number theory):
The totient function:
::* &nbsp; counts the integers up to a given positive integer &nbsp; <big>'''n'''</big> &nbsp; that are relatively prime to &nbsp; <big>'''n'''</big>
::* &nbsp; counts the integers &nbsp; <big>'''k'''</big> &nbsp; in the range &nbsp; <big>'''1 ≤ k ≤ n'''</big> &nbsp; for which the greatest common divisor &nbsp; <big>'''gcd(n,k)'''</big> &nbsp; is equal to &nbsp; <big>'''1'''</big>
::* &nbsp; counts numbers &nbsp; <big>'''≤ n'''</big> &nbsp; and &nbsp; prime to &nbsp; <big>'''n'''</big>
If the totient number &nbsp; (for '''N''') &nbsp; is one less than &nbsp; '''N''', &nbsp; then &nbsp; '''N''' &nbsp; is prime.
;Task:
Create a &nbsp; '''totient''' &nbsp; function and:
::* &nbsp; Find and display &nbsp; (1 per line) &nbsp; for the 1<sup>st</sup> &nbsp; '''25''' &nbsp; integers:
::::* &nbsp; the integer &nbsp; (the index)
::::* &nbsp; the totient number for that integer
::::* &nbsp; indicate if that integer is prime
::* &nbsp; Find and display the &nbsp; ''count'' &nbsp; of the primes up to &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 100
::* &nbsp; Find and display the &nbsp; ''count'' &nbsp; of the primes up to &nbsp; &nbsp; &nbsp; 1,000
::* &nbsp; Find and display the &nbsp; ''count'' &nbsp; of the primes up to &nbsp; &nbsp; 10,000
::* &nbsp; Find and display the &nbsp; ''count'' &nbsp; of the primes up to &nbsp; 100,000 &nbsp; &nbsp; (optional)
Show all output here.
;Related task:
::* &nbsp; [[Perfect totient numbers]]
;Also see:
::* &nbsp; [[wp:Euler's_totient_function|Wikipedia: Euler's totient function]].
::* &nbsp; [http://mathworld.wolfram.com/TotientFunction.html MathWorld: totient function].
::* &nbsp; [[oeis:/A000010|OEIS: Euler totient function phi(n)]].
<br/>