Skip to main content
added 235 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 10 bytes

`@YBUG\}HM 

Try it online!Try it online! Or verify all test cases.

Explanation

` % Do...while @ % Push iteration index (1-based) YB % Convert to binary string (1 gvies '1', 2 gives '10, etc). U % Convert string to number ('10' gives 10). This is the current % solution candidate G % Push input \ % Modulo. Gives 0 if the current candidate is a multiple of the % input, which will cause the loop to exit } % Finally: execute on loop exit H % Push 2 M % Push input to the second-last normal function (`U`); that is, % the candidate that caused the loop to exit, in string form % End (implicit). If top of the stack is 0: the loop exits. % Otherwise: a new iteration is run % Display (implicit) 

MATL, 10 bytes

`@YBUG\}HM 

Try it online!

Explanation

` % Do...while @ % Push iteration index (1-based) YB % Convert to binary string (1 gvies '1', 2 gives '10, etc). U % Convert string to number ('10' gives 10). This is the current % solution candidate G % Push input \ % Modulo. Gives 0 if the current candidate is a multiple of the % input, which will cause the loop to exit } % Finally: execute on loop exit H % Push 2 M % Push input to the second-last normal function (`U`); that is, % the candidate that caused the loop to exit, in string form % End (implicit). If top of the stack is 0: the loop exits. % Otherwise: a new iteration is run % Display (implicit) 

MATL, 10 bytes

`@YBUG\}HM 

Try it online! Or verify all test cases.

Explanation

` % Do...while @ % Push iteration index (1-based) YB % Convert to binary string (1 gvies '1', 2 gives '10, etc). U % Convert string to number ('10' gives 10). This is the current % solution candidate G % Push input \ % Modulo. Gives 0 if the current candidate is a multiple of the % input, which will cause the loop to exit } % Finally: execute on loop exit H % Push 2 M % Push input to the second-last normal function (`U`); that is, % the candidate that caused the loop to exit, in string form % End (implicit). If top of the stack is 0: the loop exits. % Otherwise: a new iteration is run % Display (implicit) 
added 822 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 10 bytes

`@YBUG\}HM 

Try it online!Try it online!

Explanation

` % Do...while @ % Push iteration index (1-based) YB % Convert to binary string (1 gvies '1', 2 gives '10, etc). U % Convert string to number ('10' gives 10). This is the current % solution candidate G % Push input \ % Modulo. Gives 0 if the current candidate is a multiple of the % input, which will cause the loop to exit } % Finally: execute on loop exit H % Push 2 M % Push input to the second-last normal function (`U`); that is, % the candidate that caused the loop to exit, in string form % End (implicit). If top of the stack is 0: the loop exits. % Otherwise: a new iteration is run % Display (implicit) 

MATL, 10 bytes

`@YBUG\}HM 

Try it online!

MATL, 10 bytes

`@YBUG\}HM 

Try it online!

Explanation

` % Do...while @ % Push iteration index (1-based) YB % Convert to binary string (1 gvies '1', 2 gives '10, etc). U % Convert string to number ('10' gives 10). This is the current % solution candidate G % Push input \ % Modulo. Gives 0 if the current candidate is a multiple of the % input, which will cause the loop to exit } % Finally: execute on loop exit H % Push 2 M % Push input to the second-last normal function (`U`); that is, % the candidate that caused the loop to exit, in string form % End (implicit). If top of the stack is 0: the loop exits. % Otherwise: a new iteration is run % Display (implicit) 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 10 bytes

`@YBUG\}HM 

Try it online!