[seqfan] Re: help needed with sequences related to Kaprekar map

Richard Mathar mathar at strw.leidenuniv.nl
Wed Aug 19 21:14:48 CEST 2009


A151959(4) is 61974 (or smaller), not 62964 as currently listed:
     from the map 10026 -> 61974 -> 82962 -> 75933 -> 63954
The 62964 is in a cycle of length 4 as observed, but 61974 is just smaller.

The offset in A151959 should be changed to 1.


In Maple 9:

A151949 := proc(n)
	tdigs := convert(n,base,10) ;
        tup := sort(tdigs) ;
        add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
end:

N := 10 :
allc := [seq(10000000000000000000000000000000,i=1..N)] :

cyK := proc(n,)
	global allc,N ;
	L := [n] ;
	k := n ;
	while true do
		k := A151949(k) ;
		if k in L then
			for s from 1 do
				if op(-s,L) = k then
					cur := op(s,allc) ;
					if k < cur then
						printf("%a %d %d\n",L,s,k) ;
						
						allc := subsop(s=k,allc) ;
					fi;
					RETURN(s) ;
				fi;
			od:
			break;
		fi;
		L := [op(L),k] :
	od:
end:

for n from 1 do
	cyK(n) ;
od:




More information about the SeqFan mailing list