AlenVelocity / Is-Prime

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

Home Page:https://mawerty.github.io/Is-Prime/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • Ada
  • Apex
  • APL
  • AMONGUSISABIGSUSSYBAKAHAHAHAHAHATHISLANGUAGEISREALLYCOOLPLEASEUSEITMYLIFEDEPENDSONITORELSEPLSPLSPLSPLSPLSPLSPLSkahyghdfhmILLDIEIFYOUDONTUSEITSOPLEASEUSEITALSODONATETOMYGOFUNDMEBECAUSEIMGONNADIEBECAUSEYOUWONTUSETHISLANGUAGEURTHEIMPOSTORANDTHATISSUSIMGOINGTOCALLAMEETINGONYOUYOUVENTEDYOUSUSSYBAKA
  • Arabic
  • Arduino
  • ArnoldC
  • Assembly
  • Atto-8
  • AWK
  • Bash
  • BASIC
  • Bc
  • Beef
  • Binary
  • BoGL
  • Brainfuck
  • BQN
  • C
  • Carbon
  • CLIPS
  • Claire
  • Clojure
  • CoffeeScript
  • COBOL
  • Chef
  • Coq
  • COW
  • Crystal
  • CSS
  • CUDA
  • C++
  • C#
  • D
  • Dafny
  • Dart
  • DXL
  • Dutch
  • DreamBerd---e-acc
  • Elixir
  • Elm
  • Emojicode
  • English (markdown)
  • English (text)
  • Erlang
  • Estonian
  • F#
  • Farsi (Persian)
  • Fish
  • FORTH
  • FORTRAN 77
  • Fortran 95
  • FStar
  • German
  • Gleam
  • GO
  • Groot
  • Groovy
  • GSC
  • Haskell
  • Haxe
  • HolyC
  • Hungarian
  • HTML
  • JamogusLamogusAmogus
  • Java
  • Javascript
  • Julia
  • Kotlin
  • LaTeX
  • Latvian
  • Lean
  • Lisp
  • LiveScript
  • Lua
  • Malbolge
  • Mathematica
  • Matlab
  • MeowScript
  • Minecraft redstone
  • Minecraft mcfunction
  • Mojo
  • Monkey
  • Nepali
  • OCaml
  • Odin
  • Nim
  • Pascal
  • Perl
  • PHP
  • PureScript
  • Piet
  • PL/SQL
  • PostgreSQL
  • Powershell
  • Processing
  • Prolog
  • Python
  • q
  • Q#
  • R
  • Racket
  • Rockstar
  • Romanian
  • Ruby
  • Rust
  • Scala
  • Shakespeare Programming Language (SPL)
  • SIC-1 Assembly
  • Scheme
  • Schlange
  • Solidity
  • Spanish
  • Standard ML
  • STEP-7 AWL
  • SQL
  • Squirrel
  • Swift
  • SystemVerilog
  • Tcl
  • Terraform
  • Toit
  • TrumpScript
  • Typescript
  • Unreal-Engine Blueprints
  • V
  • V3D
  • Vala
  • VHDL
  • VisualBasic
  • Vietnamese
  • Vimscript
  • Webassembly
  • Wenyan
  • Whitespace
  • X++
  • Zig
  • Mira
  • LabVIEW
  • Circuit

About

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

https://mawerty.github.io/Is-Prime/

License:Other


Languages

Language:HTML 22.4%Language:Cuda 8.8%Language:CSS 4.1%Language:COBOL 3.3%Language:CLIPS 2.8%Language:C# 2.7%Language:Shell 2.5%Language:Fortran 2.3%Language:Dafny 2.2%Language:Haxe 1.9%Language:VHDL 1.9%Language:C++ 1.6%Language:SystemVerilog 1.6%Language:Solidity 1.6%Language:Java 1.5%Language:Visual Basic 6.0 1.2%Language:Apex 1.1%Language:Vala 1.1%Language:PLSQL 1.1%Language:MoonScript 1.0%Language:Rust 0.9%Language:Prolog 0.9%Language:Tcl 0.9%Language:Ada 0.9%Language:Visual Basic .NET 0.9%Language:WebAssembly 0.8%Language:LOLCODE 0.8%Language:Erlang 0.8%Language:Pascal 0.8%Language:Scala 0.8%Language:PureScript 0.8%Language:Brainfuck 0.7%Language:D 0.7%Language:Assembly 0.7%Language:TeX 0.7%Language:Elixir 0.6%Language:Q# 0.6%Language:Coq 0.6%Language:M 0.6%Language:TypeScript 0.6%Language:Odin 0.6%Language:Swift 0.6%Language:Processing 0.6%Language:C 0.5%Language:Elm 0.5%Language:PowerShell 0.5%Language:F* 0.5%Language:PHP 0.5%Language:Squirrel 0.5%Language:Go 0.5%Language:Zig 0.5%Language:Vim Script 0.5%Language:Lua 0.5%Language:Racket 0.4%Language:Cool 0.4%Language:Lean 0.4%Language:HolyC 0.4%Language:Groovy 0.4%Language:Monkey 0.4%Language:Python 0.4%Language:Crystal 0.4%Language:Gleam 0.4%Language:Awk 0.4%Language:Haskell 0.4%Language:HCL 0.4%Language:Kotlin 0.4%Language:Dart 0.4%Language:GSC 0.4%Language:Ruby 0.4%Language:Scheme 0.4%Language:JavaScript 0.3%Language:OCaml 0.3%Language:F# 0.3%Language:R 0.3%Language:mcfunction 0.3%Language:LiveScript 0.3%Language:Clojure 0.3%Language:Standard ML 0.3%Language:Common Lisp 0.3%Language:Nim 0.3%Language:Toit 0.3%Language:q 0.2%Language:CoffeeScript 0.2%Language:Forth 0.2%Language:Julia 0.2%Language:Raku 0.2%Language:Witcher Script 0.1%Language:Perl 0.1%Language:NewLisp 0.0%Language:SourcePawn 0.0%Language:APL 0.0%