Iam_Sandeep

Factorial of Large number using array

Nov 26th, 2021 (edited)
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. link:https://www.geeksforgeeks.org/factorial-large-number/
  2. class Solution:
  3.     def factorial(self, N):
  4.         #code here
  5.         arr=[0]*500
  6.         arr[0]=1
  7.         global size
  8.         size=1
  9.         def mul(n):
  10.             global size
  11.             i,carry=0,0
  12.             while carry!=0 or i<size:
  13.                 prod=arr[i]*n+carry if i<size else 0
  14.                 carry=prod//10
  15.                 arr[i]=prod%10
  16.                 i=i+1
  17.             size=i
  18.  
Add Comment
Please, Sign In to add comment