(nlength N) -> 4080, (time (nlist N)) -> 0.325 secs, extensible via Shen

23 views
Skip to first unread message

fuzzy wozzy

unread,
Jun 19, 2021, 6:15:15 PM6/19/21
to Shen
(define nlength
    N -> (nlength-h N 10 1))

(define nlength-h
    N M C -> (nlength-h N (* M 10) (+ C 1)) where (>= N M)
    _ _ C -> C)

(define mu
    N -> [number>0] where (not (> N 0))
    N -> (mu-0 N 1))

(define mu-0
    1 A -> A
    N A -> (mu-0 (- N 1) (* 10 A)))

(define nx
    N ML -> (nx-h N ML 0))
 
(define nxh-h
    N ML C -> C where (< N ML)
    N ML C -> (nx-h (- N ML) ML (+ C 1)))

(define nlist
    N -> (nlist-h N (nlength N) (mu (nlength N)) [] ))

(define nlist-h
    N ` ML Ans -> (append Ans [N])
    N NL ML Ans -> (nlist-h (- N (* nx N ML) ML))
                                              (- NL 1) (/ ML 10)
                                              (append Ans [(nx N ML)] )))
   
Reply all
Reply to author
Forward
0 new messages