Palindromic Number (original) (raw)
Sample Programs in Every Language
A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Published on 07 October 2020 (Updated: 20 April 2025)
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.
This article was written by:
- Jeremy Grifski
Description
A palindromic number is a number that reads the same backward and forward. Example: 343, 121, 909, 222
Requirements
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.
Testing
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Palindromic Number. In order to keep things simple, we split up the testing as follows:
- Palindromic Number Valid Tests
- Palindromic Number Invalid Tests
Palindromic Number Valid Tests
Description | Input | Output |
---|---|---|
Sample Input: One Digit | "7" | "true" |
Sample 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" |
Palindromic Number Invalid Tests
Description | Input |
---|---|
No Input | |
Empty Input | "" |
Invalid Input: Not A Number | "a" |
Invalid Input: Negative Integer | "-7" |
Invalid Input: Float | "5.41" |
All of these tests should output the following:
Usage: please input a non-negative integer
Articles
There are 25 articles:
- Palindromic Number in Algol68
- Palindromic Number in Awk
- Palindromic Number in Beef
- Palindromic Number in C
- Palindromic Number in C#
- Palindromic Number in C++
- Palindromic Number in Commodore Basic
- Palindromic Number in Elvish
- Palindromic Number in Euphoria
- Palindromic Number in Go
- Palindromic Number in Java
- Palindromic Number in Javascript
- Palindromic Number in Julia
- Palindromic Number in Kotlin
- Palindromic Number in Mathematica
- Palindromic Number in Pascal
- Palindromic Number in Perl
- Palindromic Number in Php
- Palindromic Number in Python
- Palindromic Number in Ruby
- Palindromic Number in Rust
- Palindromic Number in Swift
- Palindromic Number in Ti Basic
- Palindromic Number in Typescript
- Palindromic Number in Wren