login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A087062 Array T(n,k) = lunar product n*k (n >= 1, k >= 1) read by antidiagonals. 30

%I #55 Nov 15 2018 10:52:59

%S 1,1,1,1,2,1,1,2,2,1,1,2,3,2,1,1,2,3,3,2,1,1,2,3,4,3,2,1,1,2,3,4,4,3,

%T 2,1,1,2,3,4,5,4,3,2,1,10,2,3,4,5,5,4,3,2,10,11,10,3,4,5,6,5,4,3,10,

%U 11,11,11,10,4,5,6,6,5,4,10,11,11,11,12,11,10,5,6,7,6,5,10,11,12,11,11,12,12

%N Array T(n,k) = lunar product n*k (n >= 1, k >= 1) read by antidiagonals.

%C See A087061 for definition. Note that 0+x = x and 9*x = x for all x.

%C This differs from A003983 at a(46): min(1,10)=1, while lunar product 10*1 = 10.

%C We have now changed the name from "dismal arithmetic" to "lunar arithmetic" - the old name was too depressing. - _N. J. A. Sloane_, Aug 06 2014

%H Alois P. Heinz, <a href="/A087062/b087062.txt">Table of n, a(n) for n = 1..10011</a>

%H D. Applegate, <a href="/A087061/a087061.txt">C program for lunar arithmetic and number theory</a>

%H D. Applegate, M. LeBrun and N. J. A. Sloane, <a href="http://arxiv.org/abs/1107.1130">Dismal Arithmetic</a>, arXiv:1107.1130 [math.NT], 2011.

%H Brady Haran and N. J. A. Sloane, <a href="https://youtu.be/cZkGeR9CWbk">Primes on the Moon (Lunar Arithmetic)</a>, Numberphile video, Nov 2018.

%H <a href="/index/Di#dismal">Index entries for sequences related to dismal (or lunar) arithmetic</a>

%e Lunar multiplication table begins:

%e 1 1 1 1 1 ...

%e 1 2 2 2 2 ...

%e 1 2 3 3 3 ...

%e 1 2 3 4 4 ...

%e 1 2 3 4 5 ...

%p # convert decimal to string: rec := proc(n) local t0,t1,e,l; if n <= 0 then RETURN([[0],1]); fi; t0 := n mod 10; t1 := (n-t0)/10; e := [t0]; l := 1; while t1 <> 0 do t0 := t1 mod 10; t1 := (t1-t0)/10; l := l+1; e := [op(e),t0]; od; RETURN([e,l]); end;

%p # convert string to decimal: cer := proc(ep) local i,e,l,t1; e := ep[1]; l := ep[2]; t1 := 0; if l <= 0 then RETURN(t1); fi; for i from 1 to l do t1 := t1+10^(i-1)*e[i]; od; RETURN(t1); end;

%p # lunar addition: dadd := proc(m,n) local i,r1,r2,e1,e2,l1,l2,l,l3,t0; r1 := rec(m); r2 := rec(n); e1 := r1[1]; e2 := r2[1]; l1 := r1[2]; l2 := r2[2]; l := max(l1,l2); l3 := min(l1,l2); t0 := array(1..l); for i from 1 to l3 do t0[i] := max(e1[i],e2[i]); od; if l>l3 then for i from l3+1 to l do if l1>l2 then t0[i] := e1[i]; else t0[i] := e2[i]; fi; od; fi; cer([t0,l]); end;

%p # lunar multiplication: dmul := proc(m,n) local k,i,j,r1,r2,e1,e2,l1,l2,l,t0; r1 := rec(m); r2 := rec(n); e1 := r1[1]; e2 := r2[1]; l1 := r1[2]; l2 := r2[2]; l := l1+l2-1; t0 := array(1..l); for i from 1 to l do t0[i] := 0; od; for i from 1 to l2 do for j from 1 to l1 do k := min(e2[i],e1[j]); t0[i+j-1] := max(t0[i+j-1],k); od; od; cer([t0,l]); end;

%t ladd[x_, y_] := FromDigits[MapThread[Max, IntegerDigits[#, 10, Max@IntegerLength[{x, y}]] & /@ {x, y}]];

%t lmult[x_, y_] := Fold[ladd, 0, Table[10^i, {i, IntegerLength[y] - 1, 0, -1}]*FromDigits /@ Transpose@Partition[Min[##] & @@@ Tuples[IntegerDigits[{x, y}]], IntegerLength[y]]];

%t Flatten[Table[lmult[k, n - k + 1], {n, 1, 13}, {k, 1, n}]] (* _Davin Park_, Oct 06 2016 *)

%o (Python)

%o def lunar_add(n,m):

%o sn, sm = str(n), str(m)

%o l = max(len(sn),len(sm))

%o return int(''.join(max(i,j) for i,j in zip(sn.rjust(l,'0'),sm.rjust(l,'0'))))

%o def lunar_mul(n,m):

%o sn, sm, y = str(n), str(m), 0

%o for i in range(len(sm)):

%o c = sm[-i-1]

%o y = lunar_add(y,int(''.join(min(j,c) for j in sn))*10**i)

%o return y # _Chai Wah Wu_, Sep 06 2015

%o (PARI) lmul=A087062(m,n,d(n)=Vecrev(digits(n)))={sum(i=1,#(n=d(n))-1+#m=d(m), vecmax(vector(min(i,#n),j,if(#m>i-j,min(n[j],m[i-j+1]))))*10^i)\10} \\ _M. F. Hasler_, Nov 13 2017

%Y Cf. A087061 (addition), A003983 (min), A087097 (lunar primes).

%Y See A261684 for a version that includes the zero row and column.

%K nonn,tabl,nice,base,look

%O 1,5

%A _Marc LeBrun_, Oct 09 2003

%E Maple programs from _N. J. A. Sloane_.

%E Incorrect comment and Mathematica program removed by _David Applegate_, Jan 03 2012

%E Edited by _M. F. Hasler_, Nov 13 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 11 05:02 EDT 2024. Contains 372388 sequences. (Running on oeis4.)