The programme inserts symbolics in the Sequence App to produce the sequence of numbers having right-most digit composite.
For more info please see
https://oeis.org/A262389
Code:
RECURSE(U,U2(N-2),4,6)►U1(N):
CHECK 1:
RECURSE(U,U3(N-2),8,9)►U2(N):
RECURSE(U,U3(N-1)+U2(N-2)-U1(N-1),14,16)►U3(N):
The 3 recursions can be telescoped into one, producing a faster method of generating the series.
Code:
RECURSE(U,IFTE(N>5,U1(N-1)+U1(N-4)-U1(N-5),IFTE(N==5,14,IFTE(N==4,9,8))),4,6)►U1(N):
CHECK 1:
Although I find the first version more pretty.
Here is a direct formula tested on the Prime as I don't have a 38G:
Code:
U(N)=10*IP((N-1)/4)+2*(N MOD 4)+7*NOT(N MOD 4)+2
Bravo Didier!
On 38G you must have brackets around (NOT(N MOD 4)) then it works OK.
I tried a formula, but yours beats mine.
Here's mine:
Code:
RECURSE(U,(5*N+1-U2(N)+(3+U2(N))*U2((2*N-3-U2(N))/4)/2)/2,4,6)►U1(N):
CHECK 1:
RECURSE(U,IFTE(N MOD 2,-1,1),-1,1)►U2(N):
just for the record.
Explicitly, this is what Didier's formula should look like on the 38G:
Code:
RECURSE(U,(10*INT((N-1)/4)+2*(N MOD 4)+7*NOT N MOD 4)+2
,4,6) ►U1(N):
CHECK 1:
Didier, perhaps you should inform OEIS of your formula, as it's more elegant than any on their webpage.