USING: kernel math math.functions sequences ; IN: sr : digits ( n -- d ) .5 + log10 1 + floor ; : initial ( n -- x0 ) digits [ 1 - 2 / floor 10^ ] [ odd? 2 7 ? * ] bi >integer ; : xn ( n xn-1 -- xn ) [ / ceiling ] keep + 2/ ; : xns ( n -- steps ) [ 0 ] [ initial ] bi [ tuck = not ] [ 2dup xn dup ] produce [ 2drop ] dip ;