Sieve of Eratosthenes in Ruby

前端 未结 5 1908
眼角桃花
眼角桃花 2020-12-14 20:10

Rather than scraping a Ruby version of this algorithm off the net I wanted to create my own based on its description here. However I cannot figure out two things

<         


        
5条回答
  •  自闭症患者
    2020-12-14 20:48

    or

    x = []
    Prime.each(123) do |p|
      x << p
    end
    

    There may be a way to use inject here but the inception thing hurts my head today.

提交回复
热议问题