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

Challenge for the rust program running properly. test_passed.png is t… #179

Open
wants to merge 1 commit 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
Binary file added Test_passed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.

7 changes: 6 additions & 1 deletion src/factorial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const factorial = (number) => {
// your code here

let rta = 1;
for(let i = number; i>0; i--){
rta *= i;
}
return(rta);
}

module.exports = factorial;
16 changes: 15 additions & 1 deletion src/fibonacci.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
const fibonacci = (n) => {
// your code here
let fib = [];
for (let i = 0; i < n; i++) //[1,1+]
{
if((i-2)<0)
{
fib.push(1);
}
else
{
fib.push(fib[i-2]+fib[i-1]);
}
}

return(fib);

}

module.exports = fibonacci;
13 changes: 12 additions & 1 deletion src/primalidad.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const trialDivision = (number) => {
// your code here
if (number<=1 || Math.trunc(number)!=number )
{
return false;
}
for (let i = 2; i <= Math.sqrt(number); i++)
{
if (number % i == 0)
{
return false;
}
}
return true;
}

module.exports = trialDivision;