Skip to main content
2 of 3
shaved off 2 bytes
mkst
  • 5.2k
  • 12
  • 19

#K4, 27 25 bytes

Solution:

*(1+)/[{y=x*_y%x}. 1+;]1,

Explanation:

Pretty naive. Start with list of [1, x] and increment both until no longer divisible.

*(1+)/[{y=x*_y%x}. 1+;]1, / the solution
                       1, / prepend input with 1
 (  )\[              ;]   / (loop)\[condition;start]
       {        }.        / lambda taking implicit x & y
                   1+     / add 1 (vectorised) [1, 13] => [2, 14]
             y%x          / divide y by x
            _             / floor
          y*              / multiply by x
        y=                / equals y?
  1+                      / add 1 (vectorised) [1, 13] => [2, 14]
*                         / take first [2, 14] => 2
mkst
  • 5.2k
  • 12
  • 19