Haskell Space Overflow

后端 未结 4 968
情深已故
情深已故 2020-12-10 05:51

I\'ve compiled this program and am trying to run it.

import Data.List
import Data.Ord
import qualified Data.MemoCombinators as Memo

collatzLength :: Int -&g         


        
4条回答
  •  無奈伤痛
    2020-12-10 06:32

    I think it's most likely that you're hitting integer overflow with some of the Collatz sequences, and then ending up in an "artificial" cycle that contains overflows but never hits 1. That would produce an infinite recursion.

    Remember that some Collatz sequences get very much larger than their starting number before they finally (?) end up at 1.

    Try to see if it fixes your problem to use Integer instead of Int.

提交回复
热议问题