[seqfan] Re: help needed with sequences related to Kaprekar map
Richard Mathar
mathar at strw.leidenuniv.nl
Thu Aug 20 22:10:51 CEST 2009
-----
For A151962 I get
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4,
5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3,
5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6,
2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2,
2, 5, 4, 3, 1, 2, 3, 4, 5, 2, 1, 2, 5, 4, 3, 1, 2, 3, 4, 5
with the Maple program
A151949 := proc(n)
local tup;
tup := sort(convert(n,base,10)) ;
add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
end:
A151962 := proc(n)
local tra,x ;
tra := [n] ;
x := n ;
while true do
x := A151949(x) ;
if member(x,tra,'l') then
RETURN(l-1) ;
fi;
tra := [op(tra),x] :
od:
end:
seq(A151962(n),n=0..120) ;
-----
and for A151963 we have
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7, 3, 2, 3, 7, 5,
6, 4, 4, 6, 5, 7, 3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7, 3, 2, 3, 7, 5, 6, 4, 4,
6, 5, 7, 3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7, 3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7,
3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7, 3, 2, 3, 7, 5, 6, 4, 4, 6, 5, 7, 3, 2, 3,
3, 6, 5, 4, 2, 3, 4, 5, 6, 3, 2, 3, 6, 5, 4, 2, 3, 4, 5, 6
by the Maple program
A151949 := proc(n)
local tup;
tup := sort(convert(n,base,10)) ;
add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
end:
A151963 := proc(n)
local tra,x ;
tra := [n] ;
x := n ;
while true do
x := A151949(x) ;
if x in tra then
RETURN(nops(tra)) ;
fi;
tra := [op(tra),x] :
od:
end:
seq(A151963(n),n=0..120) ;
---
For A151957 I get
0, 495, 6174, 62964, 420876, 7509843, 64308654, 753098643, 6431088654,
86420987532, 643330866654, 8764209875322, 64333308666654, 885432098765412,
6543331088666544, 88543320987665412, 975533110888664421,
8854333209876665412, 65554333108866654444, 987654321098876543211,
8876644220998775533212, 98765433210988766543211, 643333333330866666666654,
9876555432109887654443211, 64333333331108886666666654,
987655554321098876544443211, 6433333333311088866666666654,
98765543332110988876665443211, 988766544322109988776554332111,
8886664443222099987776555333112, 98876654433322099877666554332111,
987654333321111098888876666543211, 6433111111111111088888888888886654,
98765433321111110988888887666543211, 988766544322111109988888776554332111,
9876554332111111109888888887665443211,
98876655554432211099888776554444332111,
with the program
A151949 := proc(n)
local tup;
tup := sort(convert(n,base,10)) ;
add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
end:
A151957 := proc(n)
local tra,x ;
x := 10^(n-1)+2 ;
tra := [x] ;
while true do
x := A151949(x) ;
if member(x,tra,'l') then
op(l..nops(tra),tra) ;
RETURN(min(%)) ;
fi;
tra := [op(tra),x] :
od:
end:
seq(A151957(n),n=2..60) ;
---------
Richard J. Mathar
More information about the SeqFan
mailing list