Skip to content
forked from mawerty/Is-Prime

O(1) Algorithm to check if number is prime that works in 95%+ cases.

License

Notifications You must be signed in to change notification settings

Vyve-AU/Is-Prime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Is Prime

Welcome to the GitHub repository of an efficient algorithm that determines whether or not a given number is prime, with 95% accuracy in constant time (O(1)). Prime numbers have always been an interesting topic in the field of mathematics and computer science, and detecting them with high accuracy and efficiency is a challenge that has been tackled by many researchers. This algorithm uses the fact that most of the numbers are not prime, to detect a prime number.

NPM Package

If you are too lazy to implement this complex algorithm in your JS project, you can use our npm package! https://www.npmjs.com/package/is-prime-fast

Contributing

If you want to help with this project, you can make a pull request with an implementation for a language that hasn't been added before, or at least give it a star.

Guidelines

If it's possible, name your functions and variables is_prime. For the main parent class in OO languages, you should also name it is_prime. The file itself should be named main.file_extension. Also, when you add an implemention for some new language, do remember to create an optimized version of your code and add the new language to the list at the bottom section of the README.

FAQ

Is this project serious?

Yes, this is a 100% serious project.

Where does 95%+ come from?

When we take a random integer between 1 and 2,147,483,647, there are around 105,000,000 prime numbers. So, the chance that our number will be prime is ~4,88%.

How does the optimized implementation work?

Thecoderunsfasterwhentherearenouselessspacesandnewlines.

The algorithm has been implemented in the following languages:

  • Ada
  • APL
  • Arduino
  • ArnoldC
  • Assembly
  • Atto-8
  • Bash
  • Beef
  • Brainfuck
  • C
  • Claire
  • Clojure
  • CoffeeScript
  • COBOL
  • Coq
  • COW
  • C++
  • C#
  • CSS
  • CUDA
  • Dafny
  • Dart
  • DreamBerd---e-acc
  • Elixir
  • Elm
  • Emojicode
  • English (markdown)
  • English (text)
  • Erlang
  • F#
  • Farsi (Persian)
  • FORTRAN 77
  • Fortran 95
  • FStar
  • German
  • Gleam
  • GO
  • Groot
  • Groovy
  • Haskell
  • Haxe
  • HolyC
  • HTML
  • Java
  • Javascript
  • Julia
  • Kotlin
  • LaTeX
  • Lisp
  • LiveScript
  • Lua
  • Mathematica
  • Matlab
  • Mojo
  • Monkey
  • OCaml
  • Odin
  • Nim
  • Pascal
  • Perl
  • PHP
  • Piet
  • PL/SQL
  • PostgreSQL
  • Powershell
  • Prolog
  • Python
  • Q#
  • R
  • Rockstar
  • Romanian
  • Ruby
  • Rust
  • Scala
  • Solidity
  • Standard ML
  • STEP-7 AWL
  • SQL
  • Squirrel
  • Swift
  • Toit
  • TrumpScript
  • Typescript
  • V
  • Vala
  • VHDL
  • Webassembly
  • Wenyan
  • Zig

About

O(1) Algorithm to check if number is prime that works in 95%+ cases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 26.2%
  • Cuda 10.4%
  • CSS 4.8%
  • COBOL 3.9%
  • C# 3.2%
  • Fortran 2.7%
  • Other 48.8%