Skip to main content
added 726 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 2, 68 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,p=2,m=1:b/m*(n<2or f(*[n/p,n,b,b,p,p+1,m*p][n%p>0::2]))

Try it online!

Commented:

f=lambda n,b,p=2,m=1:         # recursive function taking 4 arguments
                              # n, b - inputs from the challenge
                              # p=2  - candidate for a prime dividing n
                              # m=1  - a power of p dividing the original input n
b/m*( ... )                   # floor division, this is 0 if m>b
     n<2or ...                # if n==1, return True (1), else:
           f(*[ ... ][1::2])  # if n%p>0 (p does not divide n):
        == f(n,b,p+1)         #   try next p
           f(*[ ... ][0::2])  # if n%p==0 (p divides n):
        == f(n/p,b,p,m*p)     #   divide n by p, update power of p, m

Python 2, 68 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,p=2,m=1:b/m*(n<2or f(*[n/p,n,b,b,p,p+1,m*p][n%p>0::2]))

Try it online!

Python 2, 68 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,p=2,m=1:b/m*(n<2or f(*[n/p,n,b,b,p,p+1,m*p][n%p>0::2]))

Try it online!

Commented:

f=lambda n,b,p=2,m=1:         # recursive function taking 4 arguments
                              # n, b - inputs from the challenge
                              # p=2  - candidate for a prime dividing n
                              # m=1  - a power of p dividing the original input n
b/m*( ... )                   # floor division, this is 0 if m>b
     n<2or ...                # if n==1, return True (1), else:
           f(*[ ... ][1::2])  # if n%p>0 (p does not divide n):
        == f(n,b,p+1)         #   try next p
           f(*[ ... ][0::2])  # if n%p==0 (p divides n):
        == f(n/p,b,p,m*p)     #   divide n by p, update power of p, m
added 6 characters in body
Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 2, 6968 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,k=2p=2,m=1:b/m*(n<2or f(*[n/p,n,b,k+1)if n%k else f(n/k,b,kp,m*kp+1,m*p][n%p>0::2]))

Try it online!Try it online!

Python 2, 69 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,k=2,m=1:b/m*(n<2or f(n,b,k+1)if n%k else f(n/k,b,k,m*k))

Try it online!

Python 2, 68 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,p=2,m=1:b/m*(n<2or f(*[n/p,n,b,b,p,p+1,m*p][n%p>0::2]))

Try it online!

Source Link
ovs
  • 60.6k
  • 3
  • 47
  • 161

Python 2, 69 bytes

The output is a positive integer for truthy cases and a 0 otherwise.

f=lambda n,b,k=2,m=1:b/m*(n<2or f(n,b,k+1)if n%k else f(n/k,b,k,m*k))

Try it online!