Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 204 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 9 bytes

1Æs4¡÷\Ƒ#

A full program accepting k m n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

1Æs4¡÷\Ƒ# - Main Link: k, m
1 # - count up from j=1 & find the first (3rd argument, n) truthy results of f(j, k):
 Ƒ - is (j) invariant under?:
 \ - last two links as a dyad - g(j, k):
 ¡ - repeated application...
 4 - ...number of times: 1st argument, m
 Æs - ...action: divisor sum
 ÷ - divide (by k)

Jelly, 9 bytes

1Æs4¡÷\Ƒ#

A full program accepting k m n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

1Æs4¡÷\Ƒ# - Main Link: k, m
1 # - count up from j=1 & find the first (3rd argument, n) truthy results of f(j, k):
 Ƒ - is (j) invariant under?:
 \ - last two links as a dyad - g(j, k):
 ¡ - repeated application...
 4 - ...number of times: 1st argument, m
 Æs - ...action: divisor sum
 ÷ - divide (by k)

Jelly, 9 bytes

1Æs4¡÷\Ƒ#

A full program accepting k m n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

1Æs4¡÷\Ƒ# - Main Link: k
1 # - count up from j=1 & find the first (3rd argument, n) truthy results of f(j, k):
 Ƒ - is (j) invariant under?:
 \ - last two links as a dyad - g(j, k):
 ¡ - repeated application...
 4 - ...number of times: 1st argument, m
 Æs - ...action: divisor sum
 ÷ - divide (by k)
Post Undeleted by Jonathan Allan
deleted 204 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 9 bytes

Æs3¡÷$=ð#1Æs4¡÷\Ƒ#

A full program accepting m k m n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online! Try it online!

How?

The smallest \$k\$-\$m\$-generalised-perfect-number must be greater than or equal to \$m\$ since the sum of the divisors of any number greater than one is at least one greater than itself (since it is a divisor of itself).

Æs3¡÷$=ð#1Æs4¡÷\Ƒ# - Main Link: mk, km
1 ð## - count up from j=mj=1 & find the first (3rd argument, n) truthy results of f(j, k):
 $ Ƒ - is (j) invariant under?:
  \ - last two links as a monaddyad - g(j, k):
 ¡ ¡ - repeated application...
 3 4 - ...number of times: 1st argument, m
Æs Æs - ...action: divisor sum
 ÷ ÷ - divide (by j)
 =  - equals (k)?

Jelly, 9 bytes

Æs3¡÷$=ð#

A full program accepting m k n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

The smallest \$k\$-\$m\$-generalised-perfect-number must be greater than or equal to \$m\$ since the sum of the divisors of any number greater than one is at least one greater than itself (since it is a divisor of itself).

Æs3¡÷$=ð# - Main Link: m, k
 ð# - count up from j=m & find the first (3rd argument, n) truthy results of f(j, k):
 $ - last two links as a monad - g(j):
 ¡ - repeated application...
 3 - ...number of times: 1st argument, m
Æs - ...action: divisor sum
 ÷ - divide (by j)
 =  - equals (k)?

Jelly, 9 bytes

1Æs4¡÷\Ƒ#

A full program accepting k m n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

1Æs4¡÷\Ƒ# - Main Link: k, m
1 # - count up from j=1 & find the first (3rd argument, n) truthy results of f(j, k):
 Ƒ - is (j) invariant under?:
  \ - last two links as a dyad - g(j, k):
 ¡ - repeated application...
 4 - ...number of times: 1st argument, m
 Æs - ...action: divisor sum
 ÷ - divide (by k)
Post Deleted by Jonathan Allan
edited body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 9 bytes

Æs3¡÷$=ð#

A full program accepting m k n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

The smallest \$k\$-\$m\$-generalised-perfect-number must be greater than or equal to \$k\$\$m\$ since the sum of the divisors of any number greater than one is at least one greater than itself (since it is a divisor of itself).

Æs3¡÷$=ð# - Main Link: m, k
 ð# - count up from j=m & find the first (3rd argument, n) truthy results of f(j, k):
 $ - last two links as a monad - g(j):
 ¡ - repeated application...
 3 - ...number of times: 1st argument, m
Æs - ...action: divisor sum
 ÷ - divide (by j)
 = - equals (k)?

Jelly, 9 bytes

Æs3¡÷$=ð#

A full program accepting m k n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

The smallest \$k\$-\$m\$-generalised-perfect-number must be greater than or equal to \$k\$ since the sum of the divisors of any number greater than one is at least one greater than itself (since it is a divisor of itself).

Æs3¡÷$=ð# - Main Link: m, k
 ð# - count up from j=m & find the first (3rd argument, n) truthy results of f(j, k):
 $ - last two links as a monad - g(j):
 ¡ - repeated application...
 3 - ...number of times: 1st argument, m
Æs - ...action: divisor sum
 ÷ - divide (by j)
 = - equals (k)?

Jelly, 9 bytes

Æs3¡÷$=ð#

A full program accepting m k n which prints a list representation of the first n \$k\$-\$m\$-generalised-perfect-numbers.

Try it online!

How?

The smallest \$k\$-\$m\$-generalised-perfect-number must be greater than or equal to \$m\$ since the sum of the divisors of any number greater than one is at least one greater than itself (since it is a divisor of itself).

Æs3¡÷$=ð# - Main Link: m, k
 ð# - count up from j=m & find the first (3rd argument, n) truthy results of f(j, k):
 $ - last two links as a monad - g(j):
 ¡ - repeated application...
 3 - ...number of times: 1st argument, m
Æs - ...action: divisor sum
 ÷ - divide (by j)
 = - equals (k)?
Post Undeleted by Jonathan Allan
added 350 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
Post Deleted by Jonathan Allan
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading

AltStyle によって変換されたページ (->オリジナル) /