Skip to main content
added 7 characters in body
Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284

Lean, 108 100 95 7878 75 bytes

def d(f g:_->int)(n):=(list.range$n+1iota n).foldr(λd s,ite(n%d=0)(s+f d*g(n/d))s)0

Try it online!Try it online!

More testcases with all of the functions.More testcases with all of the functions.

Lean, 108 100 95 78 bytes

def d(f g:_->int)(n):=(list.range$n+1).foldr(λd s,ite(n%d=0)(s+f d*g(n/d))s)0

Try it online!

More testcases with all of the functions.

Lean, 108 100 95 78 75 bytes

def d(f g:_->int)(n):=(list.iota n).foldr(λd s,ite(n%d=0)(s+f d*g(n/d))s)0

Try it online!

More testcases with all of the functions.

deleted 30 characters in body
Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284

Lean, 108 100 9595 78 bytes

import data.list
def d(f g:_->int)(n):=((list.range$n+1).mapfoldr(λd s,condite(n%d=0)(fs+f d*g(n/d))0)s).sum0

Try it online!Try it online!

More testcases with all of the functions.More testcases with all of the functions.

Lean, 108 100 95 bytes

import data.list
def d(f g:_->int)(n):=((list.range$n+1).map(λd,cond(n%d=0)(f d*g(n/d))0)).sum

Try it online!

More testcases with all of the functions.

Lean, 108 100 95 78 bytes

def d(f g:_->int)(n):=(list.range$n+1).foldr(λd s,ite(n%d=0)(s+f d*g(n/d))s)0

Try it online!

More testcases with all of the functions.

deleted 9 characters in body
Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284

Lean, 108108 100 95 bytes

import data.list.basic
def d(f g:_->int)(n):=((list.range$n+1).map(fun dλd,if n%d=0then cond(n%d=0)(f d*g(n/d)else )0)).sum

Try it online!Try it online!

More testcases with all of the functions.More testcases with all of the functions.

Lean, 108 bytes

import data.list.basic
def d(f g:_->int)(n):=((list.range$n+1).map(fun d,if n%d=0then f d*g(n/d)else 0)).sum

Try it online!

More testcases with all of the functions.

Lean, 108 100 95 bytes

import data.list
def d(f g:_->int)(n):=((list.range$n+1).map(λd,cond(n%d=0)(f d*g(n/d))0)).sum

Try it online!

More testcases with all of the functions.

Source Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284
Loading