Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. var fact = 1;
  2. var numero = 1;
  3. var primos = []
  4. var sumaPrimos = function (numero) {
  5. if (numero > 10000) {
  6. console.log("Suma de números primos:" + fact);
  7. var maximo = primos[primos.length - 1];
  8. console.log("el mayor factor primo del número 600851475143 es :" + maximo + ".");
  9. } else {
  10. if (600851475143 % numero === 0) {
  11. factor = (numero / 2);
  12. if (factor % 2 === 0 || factor % 3 === 0) {
  13. return ("error")
  14. } else {
  15. console.log(numero);
  16. primos.push(numero);
  17. fact *= numero;
  18. }
  19. }
  20. numero++
  21. sumaPrimos(numero)
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement