Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

IF TRIPS

Name: Anonymous 2013-06-04 15:05

I WILL KILL YOU

Name: Anonymous 2013-06-05 2:01

For fun:
(define (bases i)
    (define (base-iter l i n)
      (cond ((> i (- n 2)) l)
            (else (if (= (remainder n i) (remainder (floor (/ n i)) i)) (base-iter (cons i l) (+ i 1) n) (base-iter l (+ i 1) n)))))
    (base-iter '() 2 i))

(define (dubs n)
  (display (foldr string-append "" (list "[b]" (number->string n) "[/b] has")))
  (let ((base-list (bases n)))
    (cond ((empty? base-list) (display " no dubs."))
          (else (begin (display " dubs ") (print-dubs base-list n))))))

(define (print-dubs l n)
  (cond ((empty? l) (void))
        (else (let ((punctuation (cond ((empty? (cdr l)) ".")
                                       ((empty? (cddr l)) " and ")
                                       (else ", ")))
                    (dub-digit (number->string (remainder n (car l)))))
                (display (foldr string-append "" (list dub-digit "|" dub-digit " in base[sub]" (number->string (car l)) "[/sub]" punctuation))))
              (print-dubs (cdr l) n))))


>>141
141 has dubs 3|3 in base46 and 6|6 in base9.
>>142
142 has dubs 2|2 in base70.
>>143
143 has dubs 11|11 in base12, 5|5 in base6, 3|3 in base5, 3|3 in base4, 2|2 in base3 and 1|1 in base2.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List