important speedup of A006255 calculation