A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Palindromic Number page! Here, you’ll find a description of the project as well as a list of sample programs written in various languages.
A palindromic number is a number that reads the same backward and forward. Example: 343, 121, 909, 222
To implement this algorithm, your program should accept a positive integer from the command line as follows:
./palindromic-number.lang 56765
And report whether or not that number is a palindrome using the values “true” and “false.” See testing below for examples.
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Palindromic Number. To keep things simple, we split up testing into two subsets: valid and invalid. Valid tests refer to tests that occur under correct input conditions. Invalid tests refer to tests that occur on bad input (e.g., letters instead of numbers).
Description | Positive Integer | Output |
---|---|---|
sample input: one digit | 7 | true |
sampel input: even digits | 2442 | true |
sample input: odd digits | 232 | true |
sample input: even digits not palindrome | 5215 | false |
sample input: odd digits not palindrome | 521 | false |
Description | Input |
---|---|
no input | None |
empty input | ”” |
invalid input: not a number | a |
invalid input: negative number | -5 |
invalid input: float | 5.41 |
All invalid tests should spit out a usage statement in the following form:
Usage: please input a non-negative integer