Skip to content

Commit 805ac04

Browse files
Add to DIRECTORY.md
1 parent 7019a59 commit 805ac04

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

DIRECTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
* [Fibonacci](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/fibonacci.r)
8686
* [First N Fibonacci](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/first_n_fibonacci.r)
8787
* [Greatest Common Divisor](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/greatest_common_divisor.r)
88+
* [Palindrome Check](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/isPalindrome.r)
8889
* [Josephus Problem](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/josephus_problem.r)
8990
* [Least Common Multiple](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/least_common_multiple.r)
9091
* [Modular Exponentiation](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/modular_exponentiation.r)

mathematics/isPalindrome.r

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Palindrome Number Checking in R
1+
#' Check if a number is a palindrome
2+
#'
3+
#' @description Checks if an integer is a palindrome (reads the same forwards
4+
#' and backward) without using strings. Negative numbers are not palindromes.
5+
#' @param number The integer to check.
6+
#' @return TRUE if the number is a palindrome, FALSE otherwise.
7+
#' @examples
8+
#' isPalindrome(121)
9+
#' isPalindrome(123)
10+
211
isPalindrome <- function(number) {
312
# Negative numbers are not considered palindromes
413
if (number < 0L) {

0 commit comments

Comments
 (0)