Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
3 deleted 6 characters in body
source | link

Racket 143134 bytes

(let((s(number->string n))(h string->number)(g substring))(for/sum((i(range 1(string-length s))))
 (modulo n(apply +(map string->number(listh(g s 0 i))(h(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (h string->number)
        (g substring))
    (for/sum ((i (range 1 (string-length s))))
      (modulo n (apply + (map string->number (listh (g s 0 i)) (h (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476

Racket 143 bytes

(let((s(number->string n))(g substring))(for/sum((i(range 1(string-length s))))
 (modulo n(apply +(map string->number(list(g s 0 i)(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (g substring))
    (for/sum ((i (range 1 (string-length s))))
      (modulo n (apply + (map string->number (list (g s 0 i) (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476

Racket 134 bytes

(let((s(number->string n))(h string->number)(g substring))(for/sum((i(range 1(string-length s))))(modulo n(+(h(g s 0 i))(h(g s i))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (h string->number)
        (g substring))
    (for/sum ((i (range 1 (string-length s))))
      (modulo n (+ (h (g s 0 i)) (h (g s i)))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476
2 added 1 character in body
source | link

Racket 143 bytes

(let((s(number->string n))(g substring))(for/sum((i(range 1(string-length s))))
(modulo n(apply +(map string->number(list(g s 0 i)(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (g substring))
    (for/sum ((i (range 1 (string-length s))))
      (modulo n (apply + (map string->number (list (g s 0 i) (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476

Racket 143 bytes

(let((s(number->string n))(g substring))(for/sum((i(range 1(string-length s))))
(modulo n(apply +(map string->number(list(g s 0 i)(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (g substring))
    (for/sum ((i (range 1(string-length s))))
      (modulo n (apply + (map string->number (list (g s 0 i) (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476

Racket 143 bytes

(let((s(number->string n))(g substring))(for/sum((i(range 1(string-length s))))
(modulo n(apply +(map string->number(list(g s 0 i)(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (g substring))
    (for/sum ((i (range 1 (string-length s))))
      (modulo n (apply + (map string->number (list (g s 0 i) (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476
1
source | link

Racket 143 bytes

(let((s(number->string n))(g substring))(for/sum((i(range 1(string-length s))))
(modulo n(apply +(map string->number(list(g s 0 i)(g s i)))))))

Ungolfed:

(define (f n)
  (let ((s (number->string n))
        (g substring))
    (for/sum ((i (range 1(string-length s))))
      (modulo n (apply + (map string->number (list (g s 0 i) (g s i))))))))

Testing:

(f 47852)
(f 13)
(f 111)
(f 12345)
(f 54321)
(f 3729105472)

Output:

5842
1
6
2097
8331
505598476