Skip to content

monkeyraptor/generatePrime.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

generatePrime.js

JavaScript snippet to generate Prime numbers.

Update

The snippet here and the one included in the demo are updated.

The update is that the starting number isn't included in the iteration.

How to use

generatePrime(starting_number, how_many)

The starting_number input must be larger than 1 and the how_many has to be larger than 0. Both must be positive integers.

The output is an array for valid or invalid input(s).

Example

generatePrime(3, 2); // will generate output: [5, 7]
generatePrime(15, 1); // will generate output: [17]
generatePrime(-3, 2); // will generate output: ["error info"]

Demo with UI (user interface)

Go to PortRaptor.

The methods there are the expansions of this main snippet idea.

This snippet is

included in Math Operations repository.

This is a bit different than the one in Math Operations.

The one in Math Operations will return the starting number if it's a Prime number.

About

JavaScript snippet to generate prime numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published