fork download
  1. require "test/unit"
  2.  
  3. Z=->n{[*2..n].select{|r|(2...r).all?{|m|r%m>0}}.combination(2).count{|a,b|a*b<=n}}
  4.  
  5. class SquarefreeSemiPrimeCountTests < Test::Unit::TestCase
  6. def test_correct_count
  7. assert_equal 0, Z[1]
  8. assert_equal 18, Z[62]
  9. assert_equal 124, Z[420]
  10. assert_equal 2600, Z[10000]
  11. end
  12. end
Success #stdin #stdout 1.59s 5676KB
stdin
Standard input is empty
stdout
Loaded suite prog
Started
.
Finished in 1.559560 seconds.

1 tests, 4 assertions, 0 failures, 0 errors, 0 skips

Test run options: --seed 64921