<div dir="ltr">Since summing is commutative (sum [a,b] = sum [b,a]), it doesn't matter what order they appear in. You can start out by reversing the digits and then by taking from and adding to the beginning of the list instead of the end. Also, isKeith needs to know the length of the decimal representation of n. Since you are already computing that representation in isKeithHelper, it might be best to compute this there as well and pass it into isKeith.<div><br></div><div>(Also please consider the criterion library for benchmarking.)<br><div><div><br></div><div><div>> import Data.Digits</div><div><br></div><div>> isKeith :: Int -> Bool</div><div>> isKeith n = let ds = digitsRev 10 n in isKeith' n (length ds) ds</div><div><br></div><div>> isKeith' :: Int -> Int -> [Int] ->  Bool</div><div>> isKeith' n len ds</div><div>>   | n == s = True</div><div>>   | s > n = False</div><div>>   | otherwise = isKeith' n len (take len (s : ds))</div><div>>   where s = sum ds</div><div><br></div><div>> main :: IO ()</div><div>> main = print (isKeith 197)</div></div><div><br></div><div>True</div><div><br></div></div></div></div>