0
needed help on this issue, I managed to solve it perfectly but in the exits I think it is a little better!
7) Make an algorithm that calculates and displays the sum of the first 30 terms of the grade:
480 -
475 + 470 - 465 ...
10 11 12 13 (these are fractions, respectively with numerator and denominator, but I couldn’t even represent them here)
in my resolution the exits were like this:
The numerator of fraction 01 is: 475 The denominator of fraction 01 is: 11 With signal: Negative
but wanted more objectively presenting the fraction itself with the sign, but found no way, my code is as follows,
var numerador = 480
var denominador = 10
var sinal = "Positivo"
for(i=0;i<=29;i++){
numerador-=5
denominador++
if(sinal=="Negativo"){
sinal = "Positivo"
}else{
sinal = "Negativo"
}
console.log("O numerador da fração " + i+1+" é: "+ numerador+"\nO denominador da fração " + i + 1 + " é: " + denominador+"\nCom sinal: " + sinal )
}
What is the format of these numbers
480 - 475 + 470 - 465
? is a string? array?– Sergio
are normal whole numbers
– Gabriel Vieira
But you have the numbers like this:
var numeros = '480 - 475 + 470 - 465';
or so:var numeros = [480, -475, 470, -465];
?– Sergio