RosettaCodeData/Task/Tau-number/Racket/tau-number.rkt
2023-07-01 13:44:08 -04:00

19 lines
555 B
Racket
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#lang racket
(define limit 100)
(define (divisor-count n)
(length (filter (λ (x) (zero? (remainder n x))) (range 1 (+ 1 n)))))
(define (display-tau-numbers (n 1) (count 1))
(when (<= count limit)
(if (zero? (remainder n (divisor-count n)))
(begin
(printf (~a n #:width 5 #:align 'right))
(when (zero? (remainder count 10))
(newline))
(display-tau-numbers (add1 n) (add1 count)))
(display-tau-numbers (add1 n) count))))
(printf "The first ~a Τau numbers are~n" limit)
(display-tau-numbers)