0

What's the problem in this ruby code?? I searched any END missing, but I don't see nothing. Please, anyone help me...

def isPrime(intNumber)
    divisores = []
    aux = intNumber
    i = 2
    while i<=aux/i 
        if aux % i == 0
            while aux % i == 0
                aux = aux / i
            end
            divisores << i
            i++
        end
    end
    divisores << aux if aux!=1 and aux!=intNumber
    return aux
end

valor = isPrime(6)
puts "saida #{valor}"

1 Answers1

1

Your problem is that i++ is not valid Ruby code. What you want is i += 1.

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158