|
|
A169920
|
|
a(n) = n*n in the arithmetic where digits are multiplied in base 10 (as usual) but when digits are to be added they are also multiplied in base 10.
|
|
3
|
|
|
0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 111, 144, 199, 306, 455, 646, 179, 424, 731, 400, 441, 564, 769, 1126, 505, 606, 829, 1124, 1481, 900, 991, 12640, 17190, 1066, 1355, 1086, 1259, 1304, 1651, 1000, 3440, 6120, 1749, 2126, 2605, 2886, 3569, 3864, 4841
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
How should the carry digits be handled? In this version they have been handled by simply adding them in the old way, which is a bit worrisome. For example, in the calculation below, when the column containing 5 and 4 is "added", i.e. multiplied, there is a carry of 2, which here has been added to the 1 to get 3.
|
|
LINKS
|
|
|
EXAMPLE
|
a(14) = 14*14 = 306:
....14
....14
------
....56
...14.
------
...306
------
|
|
PROG
|
(Python)
from math import prod
n = len(str(m*m))+1
hold = list(zip(*[list(str(int(b)*m).ljust(n-1-a, "X").rjust(n-1, "X")) for a, b in enumerate(str(m))]))#List of products of long multiplication
store = []
for a, c in enumerate(hold):
if c.count('X') == len(c):
store.append(0)
else:
store.append(prod([int(b) for b in c if b.isdigit()])*10**(len(hold)-a-1))
return(sum(store))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|