To prevent the usual error when the number of factorials exceeds the acceptable range for a given type you can look the reference http://cpp.forum24.ru/?1-3-0-00000047-000-0-0-1347056992
Though it is written in Russia you can translate it with google or at least to see how many factorial numbers can fit into an object of type int.