Skip to main content
Commonmark migration
Source Link

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

###How it works

How it works

`        % Do...while
  @      %   Push current iteration index (1-based)
  tFYA   %   Duplicate. Convert number to its digits
  ts     %   Duplicate. Sum of digits
  wp     %   Swap. Product of digits
  h\     %   Concatenate. Modulo. This gives a length-2 array
  ~?     %   If the two values are zero: we found a number in the sequence
    @    %     Push that number
  ]      %   End if
  NG<    %   True if number of elements in stack is less than input
]        % End do...while. If top of the stack is true: next iteration. Else: exit
&        % Specify only one input (top of stack) for implicit display

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

###How it works

`        % Do...while
  @      %   Push current iteration index (1-based)
  tFYA   %   Duplicate. Convert number to its digits
  ts     %   Duplicate. Sum of digits
  wp     %   Swap. Product of digits
  h\     %   Concatenate. Modulo. This gives a length-2 array
  ~?     %   If the two values are zero: we found a number in the sequence
    @    %     Push that number
  ]      %   End if
  NG<    %   True if number of elements in stack is less than input
]        % End do...while. If top of the stack is true: next iteration. Else: exit
&        % Specify only one input (top of stack) for implicit display

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

How it works

`        % Do...while
  @      %   Push current iteration index (1-based)
  tFYA   %   Duplicate. Convert number to its digits
  ts     %   Duplicate. Sum of digits
  wp     %   Swap. Product of digits
  h\     %   Concatenate. Modulo. This gives a length-2 array
  ~?     %   If the two values are zero: we found a number in the sequence
    @    %     Push that number
  ]      %   End if
  NG<    %   True if number of elements in stack is less than input
]        % End do...while. If top of the stack is true: next iteration. Else: exit
&        % Specify only one input (top of stack) for implicit display
added 693 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

###How it works

`        % Do...while
  @      %   Push current iteration index (1-based)
  tFYA   %   Duplicate. Convert number to its digits
  ts     %   Duplicate. Sum of digits
  wp     %   Swap. Product of digits
  h\     %   Concatenate. Modulo. This gives a length-2 array
  ~?     %   If the two values are zero: we found a number in the sequence
    @    %     Push that number
  ]      %   End if
  NG<    %   True if number of elements in stack is less than input
]        % End do...while. If top of the stack is true: next iteration. Else: exit
&        % Specify only one input (top of stack) for implicit display

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!

###How it works

`        % Do...while
  @      %   Push current iteration index (1-based)
  tFYA   %   Duplicate. Convert number to its digits
  ts     %   Duplicate. Sum of digits
  wp     %   Swap. Product of digits
  h\     %   Concatenate. Modulo. This gives a length-2 array
  ~?     %   If the two values are zero: we found a number in the sequence
    @    %     Push that number
  ]      %   End if
  NG<    %   True if number of elements in stack is less than input
]        % End do...while. If top of the stack is true: next iteration. Else: exit
&        % Specify only one input (top of stack) for implicit display
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 21 bytes

`@tFYAtswph\~?@]NG<]&

Long and inefficient...

Try it online!