coding test/HackerRank

[HackerRank] Extra Long Factorials

잔망루피 2023. 5. 15. 19:32

⭐ 나의 풀이

#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'extraLongFactorials' function below.
#
# The function accepts INTEGER n as parameter.
#

def extraLongFactorials(n):
    # Write your code here
    if n < 2 :
        return 1
    else :
        return n * extraLongFactorials(n-1)

if __name__ == '__main__':
    n = int(input().strip())

    print(extraLongFactorials(n))

기본적인 재귀 호출 구현 문제

이 문제가 Medium이라니??

 

 


문제 출처 👇👇

https://www.hackerrank.com/challenges/extra-long-factorials/problem?isFullScreen=true 

 

Extra Long Factorials | HackerRank

Calculate a very large factorial that doesn't fit in the conventional numeric data types.

www.hackerrank.com

 

반응형

'coding test > HackerRank' 카테고리의 다른 글

[HackerRank] Matrix Layer Rotation  (1) 2023.05.18
[HackerRank] Queen's Attack 2  (0) 2023.05.17
[HackerRank] Non-Divisible Subset  (0) 2023.05.16
[HackerRank] Climbing the Leaderboard  (0) 2023.05.15
[HackerRank] Forming a Magic Square  (0) 2023.05.14