Learn R Programming

One4All (version 0.5)

checkLuhn: Check if a number passes the Luhn algorithm

Description

This function checks if a given number passes the Luhn algorithm. It is commonly used to validate credit card numbers.

Usage

checkLuhn(number)

Value

A logical value indicating whether the number passes the Luhn algorithm (TRUE) or not (FALSE).

Arguments

number

A character string of the number to check against the Luhn algorithm.

Examples

Run this code
checkLuhn("4532015112830366") # TRUE
checkLuhn("4532015112830367") # FALSE

Run the code above in your browser using DataLab