07-06-2022, 09:20 AM

Greetings,

Kindly assist to correct the code below.

It should find the factorial of a large number using arrays.

Thanks,

Kindly assist to correct the code below.

It should find the factorial of a large number using arrays.

Thanks,

` `

function factorial #n

ARRAY(int) ar

ar.create(10000)

ar[0] = 1

int ar_size = 1

int x

for x 2 x<=n

ar_size = fact( x ar ar_size)

int i

for i ar_size-1 i>=0

out ar[i]

function# fact #x #ar[] #ar_size

int c = 0

int i

for i 0 i< ar_size

int p = ar[i] * x + c

ar[i] = p % 10

c = p/10

while (c)

ar[ar_size] = c%10

c = c/10

ar_size++

ret ar_size

int main()

int n

out "Enter an integer number: "

out n

out "Factorial of " is:"<<endl

factorial(n)

ret 0

Best Regards,

Philip

Philip