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.
This article was written by:
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:
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
There are 30 articles: