Skip to main content
added 497 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 8 bytes

ÆDżṚ$SÞḢ

A monadic Link accepting a positive integer which yields a list of two positive integers.

Try it online!

How?

ÆDżṚ$SÞḢ - Link: positive integer, X   e.g. 12
ÆD       - divisors of X                    [1,2,3,4,6,12]
    $    - last two links as a monad:
   Ṛ     -   reverse                        [12,6,4,3,2,1]
  ż      -   zip                            [[1,12],[2,6],[3,4],[4,3],[6,2],[12,1]]
      Þ  - sort by:
     S   -   sum                            [[3,4],[4,3],[2,6],[6,2],[1,12],[12,1]]
       Ḣ - head                             [3,4]

Jelly, 8 bytes

ÆDżṚ$SÞḢ

A monadic Link accepting a positive integer which yields a list of two positive integers.

Try it online!

Jelly, 8 bytes

ÆDżṚ$SÞḢ

A monadic Link accepting a positive integer which yields a list of two positive integers.

Try it online!

How?

ÆDżṚ$SÞḢ - Link: positive integer, X   e.g. 12
ÆD       - divisors of X                    [1,2,3,4,6,12]
    $    - last two links as a monad:
   Ṛ     -   reverse                        [12,6,4,3,2,1]
  ż      -   zip                            [[1,12],[2,6],[3,4],[4,3],[6,2],[12,1]]
      Þ  - sort by:
     S   -   sum                            [[3,4],[4,3],[2,6],[6,2],[1,12],[12,1]]
       Ḣ - head                             [3,4]
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 8 bytes

ÆDżṚ$SÞḢ

A monadic Link accepting a positive integer which yields a list of two positive integers.

Try it online!