Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object hackerrank {
- object Solution {
- def main(args: Array[String]) {
- def fact(n: Int): Int = if (n == 1) 1 else n * fact(n - 1)
- for (n <- io.Source.stdin.getLines) {
- print(fact(Integer.parseInt(n.toString)) + "\n")
- }
- }
- }
- val stdinString = "2\n3\n5"
- System.setIn(new java.io.ByteArrayInputStream(stdinString.getBytes("UTF-8")))
- Solution.main(null)
- }
Add Comment
Please, Sign In to add comment