Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primer reto del Near Developer Program CUMPLIDO - [email protected] #160

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## DESCRIPTION

Nombre:
Usuario Platzi:
Nombre: nahum
Usuario Platzi: [email protected]

## Reto:

- [ ] Primer problema
- [ ] Segundo problema
- [ ] Tercer problema
- [x] Primer problema
- [x] Segundo problema
- [x] Tercer problema
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/factorial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const factorial = (number) => {
// your code here
var result = number;
if (number === 0 || number === 1)
return 1;
while (number > 1) {
number--;
result *= number;
}
return result;
}

module.exports = factorial;
19 changes: 18 additions & 1 deletion src/fibonacci.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
const fibonacci = (n) => {
// your code here

if (!n) return;

var fibArr = [1];

if (n === 1) {
console.log(fibArr);
return fibArr;
}

fibArr.push(1);

for(var i = 2, len = n; i < len; i++) {
fibArr.push(fibArr[i-1] + fibArr[i-2]);
}
console.log(fibArr);
return fibArr;

}

module.exports = fibonacci;
22 changes: 21 additions & 1 deletion src/primalidad.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
const trialDivision = (number) => {
// your code here
if(number % 1 == 0){
for (var i = 2; i < number; i++) {
if (number % i === 0) {
console.log(false);
return false;
}

}

if (number === 1 || number === -1 || number === 0) {
console.log(false);
return false;
} else {
console.log(true);
return true;
}
}else{
console.log(false);
return false;
}

}

module.exports = trialDivision;