Factor + math.extras math.unicode project-euler.common
, 8383 81 bytes
[ 0 swap [ [ dup+ ,] keep number>digits differences vabs digits>number ] until-zero ] f make Σ ]
Attempt This Online!Attempt This Online!
[ ... ] f make
Allows us to build a sequence.f
is the exemplar and is a shorter way to write{0 }
, meaning the result should be an array. Inside themake
quotation,,swap
adds an element toInitialize the sequence we're buildingsum.[ ... ] until-zero
Call a quotation until its result is 0, dropping the 0 from the stack.dup[ ,+ ] keep
Add the current numbersummand to the sequence we're buildingour sum.number>digits differences vabs digits>number
Get the next summand.Σ
Sum of a sequence.