-
Notifications
You must be signed in to change notification settings - Fork 129
Added Functions: isPrime, sumAll, Naive Search #141
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
base: master
Are you sure you want to change the base?
Conversation
Added Functions: Sum All, Naive Search, Is Prime
fixed for erros
fixed errors
fixed errors
fixed tests
* References: https://javascript.plainenglish.io/11-mathematical-algorithms-in-modern-javascript-bce71318e2da | ||
*/ | ||
const isprime = (num) => { | ||
const limit = Math.floor(Math.sqrt(num)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before this you have to verify if the number are greater or equal to 1 or if is a integer
if (num <= 1 || !Number.isInteger(num)) {
return false;
}
const isprime = require('../../../src').algorithms.math.isprime; | ||
|
||
const assert = require('assert'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put testing for negative number and float
* Calculates the sum of all numbers in an array | ||
* @param {Array} arr of two ints where arr[0] start, arr[1] end | ||
* @return {Number} sum sum of the range of numberse | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the wanted function and you implement is different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make change on isPrime and sumAll (use camel case). And review your testing value
Description of new feature, or changes
Three functions were created one under the search directory (naive_search) and two under the sum directory (is_prime and sum_all). The index.js in each directory was also edited to include new functions. Three tests were also implemented for the respective functions.
Checklist
Related Issues and Discussions
People to notify