Programming Questions

  • Newest
  • Popular Tags
  • Ask Question
  • Prime Mover unexpected end
    def PrimeMover(xth_prime) number = 2 primes = [] until xth_prime == primes.length if is_prime?(number) primes << number end number += 1 end return primes.last end def is_prime? (number) return false if number < 2 return true if number == 2 (2...number).each do |iterator| if (number % iterator) == 0 return false end end return true end PrimeMover(STDIN.gets) Can any one say me why this code gets broken
    r3doc posted this question on 1/25/14 | ruby, prime
    Answers
  • +
  • 0
  • -
  • That´s the error: (eval):25: (eval):25: compile error (SyntaxError) (eval):18: syntax error, unexpected kDO_COND, expecting kEND (2...number).each do |iterator| ^(eval):21: void value expression (eval):25: syntax error, unexpected kEND, expecting $end
  • +
  • 0
  • -
  • I'm having major problems with this challenge. I've solved it numerous times successfully on my local machine (including checking every "failed" test case), but the Coderbyte ruby interpreter seems not to work for this problem(?).
  • +
  • 0
  • -
  • I'm running into similar issues. I came across this post: stackoverflow.com/questions/17754479/why-does-this-usage-of-until-in-ruby-not-work-while-another-usage-does My guess is coderbyte is using v1.8.X and that is the cause of differences on your local machine vs. coderbyte. I re-write the problems excluding the functions/blocks/syntax that seems to be the issue. It also feels like a good exercise to understand how to solve a problem multiple ways.
    Log in to write an answer.