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

added 36 characters in body
Source Link
xash
  • 11.3k
  • 1
  • 15
  • 39

Brachylog, 1918 bytes

Generates the sequences with duplicates.

;X{tfk+}a({tN~h?k≠≠tNfk+}a(At~hAk

Try it online! Try it online!

How it works

;X{tfk+}a({tN~h?k≠≠tNfk+}a(At~hAk  implicit input n
;X [n, something]
 { }a( }a( starting with [something], generate a list
 by applying {...} n times:
 t theall lastelements element'sare different
 ft factorsthe last element
 kN withoutis itselfa natural number
 +f summed
and its factors
 k -> [220, 284,without 220]itself
 + { } the generated listsummed
 must fulfill:
 t -> the[220, tail284, 220]
 NA is a natural numberA
 ~ht and theA's headtail
 ?~h ofis the inputhead
 kA withoutof theA
 last element
 k output A allwithout elementsthe arelast differentelement

Brachylog, 19 bytes

Generates the sequences with duplicates.

;X{tfk+}a({tN~h?k≠}

Try it online!

How it works

;X{tfk+}a({tN~h?k≠} implicit input n
;X [n, something]
 { }a( starting with [something], generate a list
 by applying {...} n times:
 t the last element's
 f factors
 k without itself
 + summed
 -> [220, 284, 220]
 { } the generated list must fulfill:
 t the tail
 N is a natural number
 ~h and the head
 ? of the input
 k without the last element
  all elements are different

Brachylog, 18 bytes

Generates the sequences with duplicates.

;X{≠tNfk+}a(At~hAk

Try it online!

How it works

;X{≠tNfk+}a(At~hAk  implicit input n
;X [n, something]
 { }a( starting with [something], generate a list
 by applying {...} n times:
  all elements are different
 t the last element
 N is a natural number
 f and its factors
 k without itself
 + summed
 -> [220, 284, 220]
 A is A
 t A's tail
 ~h is the head
 A of A
 k output A without the last element
added 36 characters in body
Source Link
xash
  • 11.3k
  • 1
  • 15
  • 39

Brachylog, 1719 bytes

Generates all the numbers for a given \$n\$, includingsequences with duplicates.

;.;X{tfk+}a({k≠&ttN~h?k≠}N

Try it online! Try it online!

How it works

;.;X{tfk+}a({k≠&ttN~h?k≠}N  implicit input n
;.;X  [n, output]something]
 { }a( starting with [output][something], generate a list
 by applying {...} n times:
 t the last element's
 f factors
 k without itself
 + summed
 -> [220, 284, 220]
 {k≠&t} } the generated list must fulfill:
 k≠t without the lasttail
 element, all elements are different
 N &t is a natural number
  ~h and the tailhead
 ? of the isinput
  k without the implicitlast outputelement
 ≠ all elements are different

Brachylog, 17 bytes

Generates all the numbers for a given \$n\$, including duplicates.

;.{tfk+}a({k≠&t}N

Try it online!

How it works

;.{tfk+}a({k≠&t}N  implicit input n
;. [n, output]
 { }a( starting with [output], generate a list
 by applying {...} n times:
 t the last element's
 f factors
 k without itself
 + summed
 -> [220, 284, 220]
 {k≠&t} the generated list must fulfill:
 k≠ without the last element, all elements are different
 &t and the tail
 is the implicit output

Brachylog, 19 bytes

Generates the sequences with duplicates.

;X{tfk+}a({tN~h?k≠}

Try it online!

How it works

;X{tfk+}a({tN~h?k≠} implicit input n
;X  [n, something]
 { }a( starting with [something], generate a list
 by applying {...} n times:
 t the last element's
 f factors
 k without itself
 + summed
 -> [220, 284, 220]
 { } the generated list must fulfill:
 t the tail
 N is a natural number
  ~h and the head
 ? of the input
  k without the last element
 ≠ all elements are different
Source Link
xash
  • 11.3k
  • 1
  • 15
  • 39

Brachylog, 17 bytes

Generates all the numbers for a given \$n\$, including duplicates.

;.{tfk+}a({k≠&t}N

Try it online!

How it works

;.{tfk+}a({k≠&t}N implicit input n
;. [n, output]
 { }a( starting with [output], generate a list
 by applying {...} n times:
 t the last element's
 f factors
 k without itself
 + summed
 -> [220, 284, 220]
 {k≠&t} the generated list must fulfill:
 k≠ without the last element, all elements are different
 &t and the tail
 is the implicit output

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