HackerRank içerisinde bulunan “Extra Long Factorials” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir tam sayının faktöriyelini bulmanız isteniyor. Bazı inputlar için faktöriyel 64-bit tam sayıyı aşabilir, bu yüzden daha büyük bir tam sayı tipi kullanmanız gerekiyor.
► HackerRank – Extra Long Factorials: https://www.hackerrank.com/challenges/extra-long-factorials/problem
► Problem açıklaması:
The factorial of the integer n, written n!, is defined as:
n! = n * (n – 1) * (n – 2) * … * 3 * 2 * 1
Function Description
Complete the extraLongFactorials function in the editor below. It should print the result and return.
extraLongFactorials has the following parameter(s):
n: an integer
Note: Factorials of n biggerThan 20 can’t be stored even in a 64-bit long 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.
We recommend solving this challenge using BigIntegers.