Extra Long Factorials in CProblem Statement: The factorial of the integer n, written n!, is defined as: n! = n x (n-1) x (n-2) x (n-3) x ………. x 3 x 2 x 1 Calculate and print the factorial of a given integer. For example, if n = 30 , we calculate 30 x 29 x 28 x ………..x 3 x 2 x 1 and get. 2 6 5 2 5 2 8 5 9 8 1 2 1 9 1 0 5 8 6 3 6 3 0 8 4 8 0 0 0 0 0 0 0 in total 33 digits. Note: Factorials of n > 20 can't be stored even in a 64 - bit long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.Description of program : The below program can calculate factorial of any number, i.e. factorial of numbers above 20 which is not feasible for an 64 bit computer. We have started with variable Output of above Code ![]()
Next TopicLeap year program in C
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week