factorial program using foldr and foldl gives stackoverflow and not with product function

716 views Asked by At

I created Factorial program using foldl and foldr as shown below. But when i try to find factorial of large number like 100000 it gives: ERROR - C stack overflow

Where as, if i use product function it gives me the result after long time.

foldl (*) 1 [1..100000] 
product [1..100000]

Why am i getting different behavior? I am new to Haskell hence trying to understand different concepts by writing program like these.

0

There are 0 answers