Palindromic Number in R

Published on 06 May 2026 (Updated: 06 May 2026)

Welcome to the Palindromic Number in R page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

args <- commandArgs(trailingOnly = TRUE)

USAGE <- "Usage: please input a non-negative integer"

if (length(args) != 1 || !nzchar(x <- args[[1]]) || !grepl("^[0-9]+$", x)) {
  cat(USAGE, "\n")
  quit(status = 1)
}

n <- as.numeric(x)
orig <- n
rev_num <- 0

while (n > 0) {
  rev_num <- rev_num * 10 + (n %% 10)
  n <- n %/% 10
}

cat(tolower(orig == rev_num), "\n")

Palindromic Number in R was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.