Lua integer won't increment -


i have simple lua function designed solve problem of consecutive prime sum. prime 41, can written sum of 6 consecutive primes:

41 = 2 + 3 + 5 + 7 + 11 + 13

this longest sum of consecutive primes adds prime below one-hundred. function:

function numofconsecprimes(limit)      = allprimes(limit/2)     length = table.getn(a)     sumsofar = 0    innersum = 0    finalsum = 0     pos = 1     items = 0       inneritems = 0  finalitems = 0     resetpos = pos      while resetpos < length     pos = resetpos     resetpos = resetpos + 1     items = 0     sumsofar = 0             while sumsofar < limit , pos < length             if isprime(sumsofar) == true innersum = sumsofar inneritems = items end             print(sumsofar)             sumsofar = sumsofar + a[pos]             print(a[pos] .."->"..sumsofar)             pos = pos + 1             items = items + 1         end     if inneritems > finalitems finalitems = inneritems finalsum = innersum  end     end end 

but reason, sumsofar won't change. i'm printing before , after addition of a[pos] , stays 0 always. i'm printing a[pos] see , values fine. what's going on?

if exact code have typo.

sumsofar = sumsofar + a[pos] 

capitalize f in first sumsofar matches other ones.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -