[seqfan] Re: Re Nice variant on A030067

Neil Sloane njasloane at gmail.com
Sun Jan 12 17:30:21 CET 2014


My Maple code in A109671 still works for me (this is Maple 16):

> f:=proc(n) option remember; local t1;

> if n = 1 then RETURN(1);

> elif n mod 2 = 0 then RETURN(f(n/2));

> else t1:= f(n-2)-f((n-1)/2);

> if t1 > 0 then RETURN(t1) else RETURN(f(n-2)+f((n-1)/2)); fi; fi; end;

f := proc(n)

local t1;

option remember;

    if n = 1 then RETURN(1)

    elif n mod 2 = 0 then RETURN(f(1/2*n))

    else

        t1 := f(n - 2) - f(1/2*n - 1/2);

        if 0 < t1 then RETURN(t1)

        else RETURN(f(n - 2) + f(1/2*n - 1/2))

        end if

    end if

end proc


>  [seq(f(n),n=1..20)];

           [1, 1, 2, 1, 1, 2, 3, 1, 2, 1, 1, 2, 3, 3, 6, 1, 5, 2, 3, 1]


Neil



More information about the SeqFan mailing list