count_of_composite_numbers.sf 287 B

123456789101112131415161718
  1. #!/usr/bin/ruby
  2. # Daniel "Trizen" Șuteu
  3. # Date: 06 June 2021
  4. # https://github.com/trizen
  5. # Count the number of composite numbers <= n.
  6. # See also:
  7. # https://oeis.org/A065855
  8. func composite_count(n) {
  9. n >= 4 || return 0
  10. n - prime_count(n) - 1
  11. }
  12. say 30.of(composite_count)