Last active
June 28, 2019 00:37
-
-
Save pajaro5/1c55116b57edd23b81b33cc1090cdd96 to your computer and use it in GitHub Desktop.
Resuelve el problema 2 de project Euler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Fibonacci Solver</title> | |
</head> | |
<body> | |
</body> | |
<script> | |
var sumaPares = 2; | |
const MAXIMO = 4000000; | |
var esPar = function(numero){ | |
if (numero%2 === 0) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
var generadorFibonacci = function(anterior,ultimo){ | |
if (anterior + ultimo > MAXIMO) { | |
return sumaPares; | |
} else { | |
nuevo = anterior + ultimo; | |
if(esPar(nuevo)){ | |
sumaPares += nuevo; | |
} | |
return generadorFibonacci(ultimo,nuevo); | |
} | |
} | |
//Prueba con numeros de la serie menores a 100 | |
//serie: 1,2,3,5,8,13,21,34,55,89 | |
//suma pares: 44 | |
console.log("suma de pares de serie Fibonacci: " + generadorFibonacci(1,2)); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
suma de los pares.
yecto Euler problema 1Python
numeroprevio=1
numeroactual=2
sumatotal=0
while numeroactual<=4000000:
if numeroactual%2==0:
sumatotal+=numeroactual
temporal=numeroactual
numeroactual=numeroactual+numeroprevio
numeroprevio=temporal
print sumatotal
1
2
3
4
5
6
7
8
9
10
numeroprevio=1
numeroactual=2
sumatotal=0
while numeroactual<=4000000:
if numeroactual%2==0:
sumatotal+=numeroactual
temporal=numeroactual
numeroactual=numeroactual+numeroprevio
numeroprevio=temporal
print sumatotal
Array con los números pares de la serie.
#include <stdio.h>
int x,tabla[100];
}
}
system("PAUSE");
return 0;
}
Array con los números impares de la serie.
int x,cont,z,i,tabla[100];
}
}
system("PAUSE");
return 0;
}
4. Array con todos los elementos de la serie.
public class ArraySerie {