Skip to content

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

Q: Is this project serious?
A: Yes, this is a 100% serious project.

Q: Where does 95%+ come from?
A: 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%.

Q: How does the optimized implementation work?
A: Thecoderunsfasterwhentherearenouselessspacesandnewlines.

The algorithm has been implemented in the following languages:

  • ABPLWNL
  • Acorn
  • ActionScript
  • Ada
  • Agda
  • 𒀝𒅗𒁺𒌑 "Akkadian Cuneiform"
  • Albanian
  • Apex
  • APL
  • APOL
  • AMONGUSISABIGSUSSYBAKAHAHAHAHAHATHISLANGUAGEISREALLYCOOLPLEASEUSEITMYLIFEDEPENDSONITORELSEPLSPLSPLSPLSPLSPLSPLSkahyghdfhmILLDIEIFYOUDONTUSEITSOPLEASEUSEITALSODONATETOMYGOFUNDMEBECAUSEIMGONNADIEBECAUSEYOUWONTUSETHISLANGUAGEURTHEIMPOSTORANDTHATISSUSIMGOINGTOCALLAMEETINGONYOUYOUVENTEDYOUSUSSYBAKA
  • Arabic
  • Arduino
  • ArnoldC
  • Assembly
  • Atto-8
  • AWK
  • Bash
  • BASIC
  • Batchfile
  • Bc
  • Beef
  • Binary
  • BoGL
  • Brainfuck
  • BQN
  • C
  • Carbon
  • Chapel
  • CLIPS
  • Claire
  • Clojure
  • Cmake
  • CoffeeScript
  • CommonJS
  • CommonTS
  • COBOL
  • Chef
  • 北語中文 "Chinese (Beiyu/Mandarin)"
  • Comma Separated Values
  • Corth
  • Coq
  • COW
  • Crystal
  • CSS
  • CSS Map file
  • CUDA
  • C++
  • C#
  • D
  • Dafny
  • Dart
  • DataWeave
  • DXL
  • Dutch
  • DreamBerd---e-acc
  • Elixir
  • Elm
  • Emojicode
  • English (markdown)
  • English (text)
  • Erlang
  • Eslint JSON
  • Estonian
  • Env
  • F#
  • Farsi (Persian)
  • Fish
  • fiz
  • FORTH
  • FORTRAN 77
  • Fortran 95
  • French
  • FStar
  • GDScript
  • German
  • Gitignore
  • Github
  • Gleam
  • GO
  • GoogleScript
  • Groot
  • Groovy
  • GSC
  • Haskell
  • Haxe
  • Hintrc
  • HolyC
  • Hungarian
  • HTML
  • Intercal
  • JamogusLamogusAmogus
  • Java
  • JavaScript
  • JavaScript Module
  • JavaScript XML
  • JSON
  • Julia
  • Kotlin
  • LaTeX
  • Latin
  • Latvian
  • Lean
  • LICENSE
  • Lisp
  • LiveScript
  • Lua
  • Local Env
  • Makefile
  • Malbolge
  • Mathematica
  • Matlab
  • MeowScript
  • Minecraft redstone
  • Minecraft mcfunction
  • ModuleJS
  • Mojo
  • Monkey
  • Morse code
  • Nepali
  • Oberon-07
  • OCaml
  • Odin
  • nya~
  • Nim
  • NPM Ignore
  • Pascal
  • Perl
  • PHP
  • Pony
  • PureScript
  • Piet
  • PL/SQL
  • Portuguese
  • PostgreSQL
  • PowerPoint
  • Powershell
  • Processing
  • Prolog
  • Python
  • Python AI/ML/DL
  • q
  • Q#
  • R
  • Racket
  • Rebol
  • React Javascript
  • React Typescript
  • RISC-V Assembly
  • Rockstar
  • Romanian
  • Ruby
  • Rust
  • SASS
  • Scala
  • Scratch
  • SCSS
  • Shakespeare Programming Language (SPL)
  • SIC-1 Assembly
  • Scheme
  • Schlange
  • Solidity
  • Spanish
  • Standard ML
  • STEP-7 AWL
  • SQF
  • SQL
  • Squirrel
  • Swift
  • SystemVerilog
  • Travis YML
  • Tcl
  • Terraform
  • Thue
  • TI-Basic
  • Toit
  • TrumpScript
  • TypeScript
  • TypeScript Declaration File
  • TypeScript Module
  • Unreal-Engine Blueprints
  • UwU
  • V
  • V3D
  • Vala
  • VHDL
  • VisualBasic
  • Vietnamese
  • Vimscript
  • WebAssembly
  • Wenyan
  • Whitespace
  • YML
  • X++
  • Zig
  • Mira
  • LabVIEW
  • Circuit
  • @everyone
  • 9f87m4atttaaaou;
  • Genesis 𐤁
  • Redscript
  • dc
  • Portugol
  • Mr. Hashemi

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