OFFSET
0,3
COMMENTS
Addition and multiplication are the same as in school, that is, done in base 10, except that there are no carries and when individual digits are added or multiplied the result is replaced by its digital root (A010888).
EXAMPLE
14*14 = 187:
..14
..14
----
..47
.14.
----
.187
----
MAPLE
A010888 := proc(n)
if n = 0 then
0;
else
1+modp(n-1, 9) ;
end if;
end proc:
carryLmult1dig := proc(a, b)
local adigs, cdigs, d, len ;
if b <= 9 then
adigs := convert(a, base, 10) ;
len := nops(adigs) ;
cdigs := [seq( A010888(b*op(d, adigs)) , d=1..len)] ;
add(op(d, cdigs)*10^(d-1), d=1..len) ;
else
error b, "not smaller than 10" ;
end if;
end proc:
carryLmult := proc(a, b)
local adigs, bdigs, c, len ;
adigs := convert(a, base, 10) ;
bdigs := convert(b, base, 10) ;
len := max(nops(adigs), nops(bdigs)) ;
c := 0 ;
for i from 1 to nops(bdigs) do
carryLmult1dig(a, op(i, bdigs)) ;
c := carryLadd(c, %*10^(i-1)) ;
end do:
c ;
end proc:
A169908 := proc(n)
carryLmult(n, n) ;
end proc: # R. J. Mathar, Jul 12 2013
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved