You are viewing a single comment's thread. Return to all comments →
Here is a solution on Racket, you only need to optimize for the last two tests.
#lang racket (define (number->list number) (if (< number 10) (cons number null) (cons (modulo number 10) (number->list (floor (/ number 10)))))) (define (super-digit number) (if (< number 10) number (super-digit (foldl + 0 (number->list number))))) (let ([number (read)] [i [read]]) (super-digit (foldl + 0 (make-list i (super-digit number)))))
Super Digit
You are viewing a single comment's thread. Return to all comments →
Here is a solution on Racket, you only need to optimize for the last two tests.