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

show environment
Source Link
chunes
  • 27.8k
  • 3
  • 32
  • 55

Factor + lists.lazy math.primes.factors math.unicode, 69(削除) 69 (削除ここまで) 65 bytes

[ 1 lfrom [ divisors [ length 1 ] keep n/v sumΣ /mod integer?0 = ] lfilter ]

Try it online! Try it online!

It's a quotation that returns an infinite lazy list of the harmonic divisor numbers.

Explanation

  • 1 lfrom an infinite lazy list of natural numbers
  • [ ... ] lfilter select numbers for which the quotation returns true
  • divisors get the divisors of a number (e.g. 6 divisors -> { 1 2 3 6 })
  • [ length 1 ] keep (e.g. { 1 2 3 6 } [ length 1 ] keep -> 4 1 { 1 2 3 6 })
  • n/v divide number by vector (e.g. 1 { 1 2 3 6 } n/v -> { 1 1/2 1/3 1/6 })
  • sumΣ take the sum
  • / divide forming a rational number
  • integer?mod 0 = is it an integera divisor?

Factor + lists.lazy math.primes.factors, 69 bytes

[ 1 lfrom [ divisors [ length 1 ] keep n/v sum / integer? ] lfilter ]

Try it online!

It's a quotation that returns an infinite lazy list of the harmonic divisor numbers.

Explanation

  • 1 lfrom an infinite lazy list of natural numbers
  • [ ... ] lfilter select numbers for which the quotation returns true
  • divisors get the divisors of a number (e.g. 6 divisors -> { 1 2 3 6 })
  • [ length 1 ] keep (e.g. { 1 2 3 6 } [ length 1 ] keep -> 4 1 { 1 2 3 6 })
  • n/v divide number by vector (e.g. 1 { 1 2 3 6 } n/v -> { 1 1/2 1/3 1/6 })
  • sum take the sum
  • / divide forming a rational number
  • integer? is it an integer?

Factor + lists.lazy math.primes.factors math.unicode, (削除) 69 (削除ここまで) 65 bytes

[ 1 lfrom [ divisors [ length 1 ] keep n/v Σ mod 0 = ] lfilter ]

Try it online!

It's a quotation that returns an infinite lazy list of the harmonic divisor numbers.

Explanation

  • 1 lfrom an infinite lazy list of natural numbers
  • [ ... ] lfilter select numbers for which the quotation returns true
  • divisors get the divisors of a number (e.g. 6 divisors -> { 1 2 3 6 })
  • [ length 1 ] keep (e.g. { 1 2 3 6 } [ length 1 ] keep -> 4 1 { 1 2 3 6 })
  • n/v divide number by vector (e.g. 1 { 1 2 3 6 } n/v -> { 1 1/2 1/3 1/6 })
  • Σ take the sum
  • mod 0 = is it a divisor?
Source Link
chunes
  • 27.8k
  • 3
  • 32
  • 55

Factor + lists.lazy math.primes.factors, 69 bytes

[ 1 lfrom [ divisors [ length 1 ] keep n/v sum / integer? ] lfilter ]

Try it online!

It's a quotation that returns an infinite lazy list of the harmonic divisor numbers.

Explanation

  • 1 lfrom an infinite lazy list of natural numbers
  • [ ... ] lfilter select numbers for which the quotation returns true
  • divisors get the divisors of a number (e.g. 6 divisors -> { 1 2 3 6 })
  • [ length 1 ] keep (e.g. { 1 2 3 6 } [ length 1 ] keep -> 4 1 { 1 2 3 6 })
  • n/v divide number by vector (e.g. 1 { 1 2 3 6 } n/v -> { 1 1/2 1/3 1/6 })
  • sum take the sum
  • / divide forming a rational number
  • integer? is it an integer?

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