I'm trying to make an algorithm here with this statement:
Given an integer n, n> 0, and a sequence with n integers, determine the sum of the positive integers of the sequence. For example, for the sequence 6-27 0 -5 2 4 your program should write the number 19.
The problem is time to add up. Here's the code I've done:
var numero;
var soma;
for (var i = 0; i < 7 ; ) {
numero=prompt("Entre com o numero: ");
parseInt(numero);
while (numero > 0) {
soma = soma + numero;
numero = 0;
}
i++;
}
document.write("A soma dos positivos é: "+soma);
What happens is that the numbers do not add up and I have no idea how to make them add up.