for(b in 3l..12)println((1..<b).collectMany(r={c,l=0->c%"\x02\x03\x05\x07\x0b\r\x11\x13\x17\x1d\x1f%)+/5".bytes[l]?([]):(0..<b).collectMany{r c*b+it,l+1}+c}).sort().sum{it+/
/})
Note that non-ascii characters in the above source code will be escaped (such as \x9f).