Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Totient-function/Racket/totient-function.rkt
Normal file
18
Task/Totient-function/Racket/totient-function.rkt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#lang racket
|
||||
|
||||
(require math/number-theory)
|
||||
|
||||
(define (prime*? n) (= (totient n) (sub1 n)))
|
||||
|
||||
(for ([n (in-range 1 26)])
|
||||
(printf "φ(~a) = ~a~a~a\n"
|
||||
n
|
||||
(totient n)
|
||||
(if (prime*? n) " is prime" "")
|
||||
(if (prime? n) " (confirmed)" "")))
|
||||
|
||||
(for/fold ([count 0] #:result (void)) ([n (in-range 1 10001)])
|
||||
(define new-count (if (prime*? n) (add1 count) count))
|
||||
(when (member n '(100 1000 10000))
|
||||
(printf "Primes up to ~a: ~a\n" n new-count))
|
||||
new-count)
|
||||
Loading…
Add table
Add a link
Reference in a new issue