/* in Picat. https://mindyourdecisions.com/blog/2017/10/01/can-you-solve-the-sum-of-6s-an-evil-math-problem/ """ What is 6 + 66 + 666 + … + 66…6 = ? Each subsequent term in the series has an extra 6, and the last term has the digit 6 repeated 666 times. This is a pretty interesting problem. """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. go => S = "6", A = [S.to_integer()], foreach(_I in 2..666) S := S ++ "6", A := A ++ [S.to_integer()] end, println(A.sum()), nl. % Another approach go2 => println(sum([['6' : _ in 1..I].to_int() : I in 1..666])).