Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
js-e003
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro Rolon
js-e003
Commits
208373cb
Commit
208373cb
authored
Oct 17, 2018
by
Pedro Rolon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arreglé la función de números primos! ya funciona
parent
8985131a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
js-e003.js
+15
-11
No files found.
js-e003.js
View file @
208373cb
...
@@ -2,25 +2,29 @@
...
@@ -2,25 +2,29 @@
//1. Escribir una funcion que imprima todos los numeros primos
//1. Escribir una funcion que imprima todos los numeros primos
//del 1 al 100
//del 1 al 100
function
primos
(){
function
primos
(){
let
contador
=
0
let
es_primo
=
true
;
for
(
i
=
1
;
i
<
101
;
i
++
){
console
.
log
(
2
);
//porque es el primer primo
for
(
j
=
3
;
j
<=
100
;
j
++
){
for
(
j
=
2
;
j
<=
Math
.
trunc
(
i
**
0.5
);
j
++
){
for
(
i
=
2
;
i
<=
Math
.
trunc
(
j
**
0.5
);
i
++
){
//console.log("i:"+i+" j:"+j+"i%j="+(i%j));
if
(
j
%
i
==
0
){
if
((
i
%
j
)
==
0
){
//console.log("no es primo");
contador
++
;
es_primo
=
false
;
break
;
break
;
}
}
//console.log(i);
}
}
if
(
contador
==
0
){
if
(
es_primo
){
console
.
log
(
i
);
console
.
log
(
j
);
contador
=
0
;
}
else
{
es_primo
=
true
;
}
}
}
}
}
}
//primos();
//primos();
// 2. Realizar el factorial de los primeros 50 numeros.
// 2. Realizar el factorial de los primeros 50 numeros.
//Ej. 1, 2... 50
//Ej. 1, 2... 50
function
factorial
(){
function
factorial
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment