ruby - Unexpected $end after while loop and nested if -


i have program working on supposed find sum of first 1000 prime numbers. concerned making sure program finding first 1000 prime numbers, add functionality adding them later. here have:

#!/usr/bin/ruby  def prime(num)      is_prime = true      in 2..math.sqrt(num)          if (num % i) == 0                        is_prime = false         else             is_prime = true         end     end      return is_prime end   = 2 number_of_primes = 0  while number_of_primes < 1000      prime = prime(i)      if prime == true         number_of_primes++      end     i++ end 

when try run program following feedback:

sumofprimes.rb:32: syntax error, unexpected keyword_end sumofprimes.rb:34: syntax error, unexpected keyword_end 

what gives? direction appreciated.

ruby doesn't have ++ operator, need += 1

number_of_primes += 1 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -