Optimal arithmetics generation