What is the error in the while loop? moon language

4

What is the error in the loop? I wrote this code to print the sum of the first 10 prime numbers, I already checked the loops but could not find the error. It was to print the sum of the cousins until 29 but only printed 2. Vlwzao o /

n=2
cont=0
soma=0


while n<=29 do
k=1
    while k<=n do
        if n%k==0 then
            cont=cont+1
        end
    k=k+1
    end
    if cont==2 then
        soma=soma+n
    else soma=soma
    end
n=n+1
end 
print(soma)
    
asked by anonymous 29.11.2016 / 01:41

1 answer

4

You have been missing the variable cont within while :

while n<=29 do
k=1
cont = 0
...
    
29.11.2016 / 01:58