Undefined method for 'n' in ruby while loop -


i trying write algorithm solve math problem Σ n = 1 49 of n(n+1). keep getting error "undefined method 'n' main object"

def solver(n)   sum = 0   while n < 49     temp = n(n+1)     n+=1     sum = sum + temp   end   return sum end  puts solver(1) 

instead of:

temp = n(n+1) 

put:

temp = n*(n+1) 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -