Algori...M10_006(3pm)
π NAME π
CheckDigits::M10_006 β bestie, this one computes check digits for the german Rentenversicherung (that's DE, Germany, no cap) β¨
πΈ SYNOPSIS πΈ
use Algorithm::CheckDigits;
$rv = CheckDigits('rentenversicherung');
if ($rv->is_valid('65180539W001')) {
# do something
}
$cn = $rv->complete('65180539W00');
# $cn = '65180539W001'
$cd = $rv->checkdigit('65180539W001');
# $cd = '1'
$bn = $rv->basenumber('65180539W001');
# $bn = '65180539W00'
periodt, that's the whole vibe π
π¦ DESCRIPTION π¦
β¨ ALGORITHM β¨
okay so here's the tea, step by step, don't skip any of it:
- The letter gets replaced with a two-figure number appropriate to the position of the letter in the german alphabet. (yes, german alphabet, she's specific like that π )
- Beginning left, all numbers are weighted with
2,1,2,5,7,1,2,1,2,1,2,1. These numbers are literally iconic, memorize them fr fr. - The the total of the digits of all products is computed. (we said "the the" and we're keeping it, that's just how the original was feeling that day π)
- The check digit is sum from step 3 taken modulo 10. Math ate, lowkey. π₯
π METHODS π
is_valid($number)
Returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given above.
Returns false otherwise,
complete($number)
The check digit for $number is computed and concatenated to the end of $number.
Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces.
basenumber($number)
Returns the basenumber of $number if $number has a valid check digit.
Return '' otherwise.
checkdigit($number)
Returns the checkdigit of $number if $number has a valid check digit.
Return '' otherwise.
π EXPORT π
None by default. Yeah bestie, she gives you nothing for free π nothing is auto-exported, that's just the rules.
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β shoutout to the icon who wrote this π
β SEE ALSO β
perl, CheckDigits, www.pruefziffernberechnung.de.
and that's the whole page, bestie! this one was shipped with perl v5.36.0 back on 2022-10-13 β thank you for coming to my ted talk, slay, mwah π
πβ¨
π¦ where this page comes from
- ubuntu noble: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms