Can I have a block in begin/while statement in Ruby?

Posted by jbjuly on Stack Overflow See other posts from Stack Overflow or by jbjuly
Published on 2010-05-30T04:09:20Z Indexed on 2010/05/30 4:12 UTC
Read the original article Hit count: 302

Filed under:
|
|

I'm trying out to have a block in a while and begin statements in Ruby, but I get a syntax error. Any other way to implement it?

Here's what I want to accomplish

(1..limit).each { |i|
  while (true) do |n|
    x = n * (i%n)
    puts n if n%i != 0
    break if x.even? && !x.zero?
    n += 1
  end
}

© Stack Overflow or respective owner

Related posts about ruby

Related posts about algorithm