Git Product home page Git Product logo

darkiee12 / is-prime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mawerty/is-prime

0.0 0.0 0.0 493 KB

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

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

License: Other

Shell 9.00% JavaScript 43.05% Ruby 1.29% C++ 5.85% Python 1.46% Perl 0.31% C 1.93% PHP 1.79% Erlang 2.90% Java 5.50% OCaml 1.23% Common Lisp 0.99% Lua 1.62% Haskell 1.36% Scala 2.81% Groovy 1.56% Fortran 8.30% Clojure 1.07% R 1.19% VHDL 6.80%

is-prime's Introduction

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
  • Agda
  • Apex
  • APL
  • AMONGUSISABIGSUSSYBAKAHAHAHAHAHATHISLANGUAGEISREALLYCOOLPLEASEUSEITMYLIFEDEPENDSONITORELSEPLSPLSPLSPLSPLSPLSPLSkahyghdfhmILLDIEIFYOUDONTUSEITSOPLEASEUSEITALSODONATETOMYGOFUNDMEBECAUSEIMGONNADIEBECAUSEYOUWONTUSETHISLANGUAGEURTHEIMPOSTORANDTHATISSUSIMGOINGTOCALLAMEETINGONYOUYOUVENTEDYOUSUSSYBAKA
  • Arabic
  • Arduino
  • ArnoldC
  • Assembly
  • Atto-8
  • AWK
  • Bash
  • BASIC
  • Bc
  • Beef
  • Binary
  • BoGL
  • Brainfuck
  • BQN
  • C
  • Carbon
  • CLIPS
  • Claire
  • Clojure
  • CoffeeScript
  • CommonJS
  • 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
  • GoogleScript
  • Groot
  • Groovy
  • GSC
  • Haskell
  • Haxe
  • HolyC
  • Hungarian
  • HTML
  • JamogusLamogusAmogus
  • Java
  • JavaScript
  • JavaScript XML
  • JSON
  • Julia
  • Kotlin
  • LaTeX
  • Latin
  • Latvian
  • Lean
  • Lisp
  • LiveScript
  • Lua
  • Malbolge
  • Mathematica
  • Matlab
  • MeowScript
  • Minecraft redstone
  • Minecraft mcfunction
  • ModuleJS
  • Mojo
  • Monkey
  • Morse code
  • Nepali
  • OCaml
  • Odin
  • Nim
  • Pascal
  • Perl
  • PHP
  • PureScript
  • Piet
  • PL/SQL
  • Portuguese
  • PostgreSQL
  • Powershell
  • Processing
  • Prolog
  • Python
  • q
  • Q#
  • R
  • Racket
  • Rebol
  • Rockstar
  • Romanian
  • Ruby
  • Rust
  • Scala
  • Scratch
  • 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
  • UwU
  • V
  • V3D
  • Vala
  • VHDL
  • VisualBasic
  • Vietnamese
  • Vimscript
  • WebAssembly
  • Wenyan
  • Whitespace
  • X++
  • Zig
  • Mira
  • LabVIEW
  • Circuit
  • @everyone

is-prime's People

Contributors

mawerty avatar darkiee12 avatar radubratan avatar skver0 avatar jstnmcbrd avatar quintusjoyal avatar salomaestro avatar linus-mussmaecher avatar patchzyy avatar sreedevt avatar xbrsq avatar arksurv avatar wanttobeeme avatar morphismz avatar notstanley4330 avatar emeraldtip avatar mkhgkk avatar laoshubaby avatar vwanders avatar exoad avatar yamin8000 avatar banjug avatar juanlufont avatar aij avatar hidetarotanaka avatar asukaminato0721 avatar jeanlucaslima avatar jasondwyer avatar jaicewizard avatar smolkomartin1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.