-
Notifications
You must be signed in to change notification settings - Fork 4
sumDigits
elcapo edited this page Oct 16, 2014
·
3 revisions
sumDigits
is an auxiliary function that sums the digits of the number received. For instance, it returns 6 for 123, as long as 1+2+3 = 6.
/* MySQL */
SELECT sumDigits( 12345 ); /* Returns 15 (= 1+2+3+4+5) */
SELECT sumDigits( 99 ); /* Returns 18 (= 9+9) */
/* JavaScript */
var digits = sumDigits( 12345 ); /* digits = 15 (= 1+2+3+4+5) */
var digits = sumDigits( 99 ); /* digits = 18 (= 9+9) */
/* PHP */
$digits = sumDigits( 12345 ); /* $digits = 15 (= 1+2+3+4+5) */
$digits = sumDigits( 99 ); /* $digits = 18 (= 9+9) */
-
[int]
- Sum, one by one, of the digits of the given string.
This function is part of the NIF, NIE & CIF package.
Go back home!
SEPA validations
- [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))
Spanish validations
- NIF, NIE & CIF
- [Spanish Bank Accounts](Spanish Bank Accounts)
Helpers
- [Common functions](Common functions)