A Collection of Code Snippets in as Many Programming Languages as Possible

This project is maintained by TheRenegadeCoder

Welcome to the Prime Number page! Here, you'll find a description of the project as well as a list of sample programs written in various languages.

A prime number is a positive integer which is divisible only by 1 and itself. For example: 2, 3, 5, 7, 11, 13

Since every number is divisible by One so, Two is the only even and the smallest prime number.

Create a file called Prime Number using the naming convention appropriate for your language of choice.

Write a sample program which accepts an integer on the command line and outputs if the integer is a Prime number or not.

Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Prime Number. In order to keep things simple, we split up the testing as follows:

- Prime Valid Tests
- Prime Invalid Tests

Description | Input | Output |
---|---|---|

Sample Input 0 | "0" | "composite" |

Sample Input 1 | "1" | "composite" |

Sample Input 2 | "2" | "prime" |

Sample Input Small Composite | "4" | "composite" |

Sample Input Small Prime | "7" | "prime" |

Sample Input Large Composite | "4011" | "composite" |

Sample Input Large Prime | "3727" | "prime" |

Description | Input |
---|---|

No Input | |

Empty Input | "" |

Invalid Input: Not A Number | "a" |

Invalid Input: Not An Integer | "6.7" |

Invalid Input: Negative | "-7" |

All of these tests should output the following:

```
Usage: please input a non-negative integer
```

- Prime Number in Algol68
- Prime Number in Bash
- Prime Number in C
- Prime Number in C#
- Prime Number in C++
- Prime Number in Cobol
- Prime Number in Euphoria
- Prime Number in Fortran
- Prime Number in Go
- Prime Number in Haskell
- Prime Number in Java
- Prime Number in Javascript
- Prime Number in Kotlin
- Prime Number in Lisp
- Prime Number in Lua
- Prime Number in Mathematica
- Prime Number in Matlab
- Prime Number in Pascal
- Prime Number in Perl
- Prime Number in Php
- Prime Number in Python
- Prime Number in R
- Prime Number in Rexx
- Prime Number in Rust