Skip to content

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

chs-mix
Copy link

@chs-mix chs-mix commented Jan 23, 2023

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

  • Your branch is up-to-date with the base branch
  • You've included at least one test if this is a new feature
  • All tests are passing

Related Issues and Discussions

People to notify

* References: https://javascript.plainenglish.io/11-mathematical-algorithms-in-modern-javascript-bce71318e2da
*/
const isprime = (num) => {
const limit = Math.floor(Math.sqrt(num));

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');

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
*/

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

Copy link

@MdialloC19 MdialloC19 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants