Skip to main content
Python
Source Link

SageMath, 91 87 bytes

a=lambda n:int(is_prime(n))or sum(a(d)*a(n//d)for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

Shortened with Neil's advice.

Albert.Lang's hint removes 'is_prime':

Python, 74 bytes

a=lambda n:max(1,sum(a(d)*a(n//d)for d in range(2,n)if d*d<=n and n%d==0))

SageMath, 91 87 bytes

a=lambda n:int(is_prime(n))or sum(a(d)*a(n//d)for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

Shortened with Neil's advice.

SageMath, 91 87 bytes

a=lambda n:int(is_prime(n))or sum(a(d)*a(n//d)for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

Shortened with Neil's advice.

Albert.Lang's hint removes 'is_prime':

Python, 74 bytes

a=lambda n:max(1,sum(a(d)*a(n//d)for d in range(2,n)if d*d<=n and n%d==0))
if/else -> int(bool)or
Source Link

SageMath, 9191 87 bytes

a=lambda n:1 if int(is_prime(n) else)or sum(a(d)*a(n//d) for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

Shortened with Neil's advice.

SageMath, 91 bytes

a=lambda n:1 if is_prime(n) else sum(a(d)*a(n//d) for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

SageMath, 91 87 bytes

a=lambda n:int(is_prime(n))or sum(a(d)*a(n//d)for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.

Shortened with Neil's advice.

Source Link

SageMath, 91 bytes

a=lambda n:1 if is_prime(n) else sum(a(d)*a(n//d) for d in range(2,n) if n%d==0 and d*d<=n)

Python apart from the function 'is_prime'.