-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpairProgramming.js
More file actions
39 lines (35 loc) · 1.04 KB
/
pairProgramming.js
File metadata and controls
39 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Objetivo: Recibir por consola un numero entero mayor que 0,
//e imprimir ese numero de digitos de fibonacci.
function generateFibonacciNumbers(inputInt) {
let aux1 = 0;
let aux2 = 1;
let aux3;
let fibonacciNumbersGenerated = [];
for (let i = 0; i < inputInt; i++) {
if(i==0) fibonacciNumbersGenerated.push(0);
if(i==1) fibonacciNumbersGenerated.push(1);
if(i>=2){
aux3 = aux1 + aux2;
aux1 = aux2;
aux2 = aux3;
fibonacciNumbersGenerated.push(aux3)}
}
return fibonacciNumbersGenerated;
}
function validateIntInput(inputInt) {
return (inputInt > 0);
}
function requestIntInput() {
let auxBoolean = true;
let valor1;
while (auxBoolean) {
valor1 = prompt("Ingrese un numero >0 y entero, porfavor", 0);
if (validateIntInput(valor1)) {
break;
}
console.log("intente nuevamente");
}
return valor1;
}
let inputInt = requestIntInput();
document.getElementById("name").innerHTML = generateFibonacciNumbers(inputInt);