HackerRank 30 days of coding – Day 9 ( Recursion)

Task :Write a factorial function that takes a positive integer, N as a parameter and prints the result of N!(N factorial).     Sample Input 3 Sample Output 6 #!/bin/python import math import os import random import re import sys def factorial(n): if n<0: return-1 elif n<2: return1 else: return n*factorial(n-1) if __name__ == ‘__main__’: … More HackerRank 30 days of coding – Day 9 ( Recursion)

Advertisements