Skip to main content
added 556 characters in body
Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71

R, 35 bytes

function(a,b,l)sum(b%/%l-(a-1)%/%l) 

Try it online!

Implementation of tsh's method by Giuseppe. 3 bytes shorter than the previous version:

R, 45 38 bytes

-7 bytes thanks to Nick Kennedy and Xi'an.

function(a,b,l)sum(!outer(a:b,l,`%%`)) 

Try it online!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

R, 45 38 bytes

-7 bytes thanks to Nick Kennedy and Xi'an.

function(a,b,l)sum(!outer(a:b,l,`%%`)) 

Try it online!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

R, 35 bytes

function(a,b,l)sum(b%/%l-(a-1)%/%l) 

Try it online!

Implementation of tsh's method by Giuseppe. 3 bytes shorter than the previous version:

R, 45 38 bytes

-7 bytes thanks to Nick Kennedy and Xi'an.

function(a,b,l)sum(!outer(a:b,l,`%%`)) 

Try it online!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

deleted 2 characters in body
Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71

R, 4545 38 bytes

-7 bytes thanks to Nick Kennedy and Xi'an.

function(a,b,l)sum(!outer(a:b,l,Negate(`%%`))) 

Try it online!

First time I have ever used Negate!Try it online!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

R, 45 bytes

function(a,b,l)sum(outer(a:b,l,Negate(`%%`))) 

Try it online!

First time I have ever used Negate!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

R, 45 38 bytes

-7 bytes thanks to Nick Kennedy and Xi'an.

function(a,b,l)sum(!outer(a:b,l,`%%`)) 

Try it online!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

added 47 characters in body
Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71

R, 45 bytes

function(a,b,l)sum(outer(a:b,l,Negate(`%%`))) 

Try it online!

First time I have ever used Negate!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

R, 45 bytes

function(a,b,l)sum(outer(a:b,l,Negate(`%%`))) 

Try it online!

First time I have ever used Negate!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R).

R, 45 bytes

function(a,b,l)sum(outer(a:b,l,Negate(`%%`))) 

Try it online!

First time I have ever used Negate!

Boils down to summing the values of !(x %% y) for x in a:b and y in l (%% is \$mod\$ in R, so x %% y == 0 iff x is a multiple of y).

Source Link
Robin Ryder
  • 15.8k
  • 2
  • 25
  • 71
Loading