first(n) = {res = List(); m = Map(); mapput(m, 0, 0); mapput(m, 1, 1); mapput(m, 6, 9); mapput(m, 8, 8); mapput(m, 9, 6); ind = Map(); mapput(ind, 0, 0); mapput(ind, 1, 1); mapput(ind, 2, 6); mapput(ind, 3, 8); mapput(ind, 4, 9); for(i = 1, oo, c = f(i); if(bigomega(c) == 2, rc = rotate(c); if(bigomega(rc) == 2, listput(res, c); if(#res >= n, return(res) ) ) ) ); } f(n) = {my(d = digits(n, 5)); d = vector(#d, i, mapget(ind, d[i])); fromdigits(d)} rotate(n) = my(d = digits(n)); d = Vecrev(vector(#d, i, mapget(m, d[i]))); fromdigits(d);