Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions HackerRank Challenges/Java/ExtraLongFatorials/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ExtraLongFatorials;

import java.math.BigInteger;
import java.util.Scanner;

public class Solution {

static BigInteger extraLongFactorials(BigInteger n) {
if (n.intValue() == 1 || n.intValue() == 0)
return new BigInteger("1");

return n.multiply(extraLongFactorials(new BigInteger(String.valueOf(n.intValue()-1))));
}

private static final Scanner scanner = new Scanner(System.in);

public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

System.out.print(extraLongFactorials(new BigInteger(String.valueOf(n))));

scanner.close();
}

}
2 changes: 2 additions & 0 deletions HackerRank Challenges/Java/ExtraLongFatorials/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is the solution for the challenge at https://www.hackerrank.com/challenges/extra-long-factorials/
Solution by [Luís Tovar](https://github.com/LuisTovar0)