Skip to main content
output on stack ...
Source Link
ბიმო
  • 16.9k
  • 2
  • 41
  • 104

dc, 2323 22 bytes

1r[dk*K1-d0<a]dsax_1*+pd0<a]dsax_1*+

Try it onlineTry it online or verify 0-125!

1r[dk*K1-d0<a]dsax_1*+pd0<a]dsax_1*+  # input on stack, eg:     4
1                        # push 1:                 1 4
 r                       # reverse top two:        4 1
  [dk*K1-d0<a]           # push [string]:          [string] 4 1
              dsa        # copy top to register a: [string] 4 1
                 x       # exec top*               0 24
                  _1     # push -1:                -1 0 24
                    *    # multiply:               0 24
                     +   # add:                    24
                      p  # print top element

# first exec of [string]:

  [dk*K1-d0<a]  # stack:                4 1
   d            # duplicate top:        4 4 1
    k           # pop & set precision:  4 1
     *          # multiply              4
      K         # push precision        4 4
       1        # push 1                1 4 4
        -       # subtract              3 4
         d0<a   # if top > 0 exec content of register a, namely [string]
                # output on stack:      24

dc, 23 bytes

1r[dk*K1-d0<a]dsax_1*+p

Try it online or verify 0-125!

1r[dk*K1-d0<a]dsax_1*+p  # input on stack, eg:     4
1                        # push 1:                 1 4
 r                       # reverse top two:        4 1
  [dk*K1-d0<a]           # push [string]:          [string] 4 1
              dsa        # copy top to register a: [string] 4 1
                 x       # exec top*               0 24
                  _1     # push -1:                -1 0 24
                    *    # multiply:               0 24
                     +   # add:                    24
                      p  # print top element

# first exec of [string]:

  [dk*K1-d0<a]  # stack:                4 1
   d            # duplicate top:        4 4 1
    k           # pop & set precision:  4 1
     *          # multiply              4
      K         # push precision        4 4
       1        # push 1                1 4 4
        -       # subtract              3 4
         d0<a   # if top > 0 exec content of register a, namely [string]

dc, 23 22 bytes

1r[dk*K1-d0<a]dsax_1*+

Try it online or verify 0-125!

1r[dk*K1-d0<a]dsax_1*+  # input on stack, eg:     4
1                       # push 1:                 1 4
 r                      # reverse top two:        4 1
  [dk*K1-d0<a]          # push [string]:          [string] 4 1
              dsa       # copy top to register a: [string] 4 1
                 x      # exec top*               0 24
                  _1    # push -1:                -1 0 24
                    *   # multiply:               0 24
                     +  # add:                    24

# first exec of [string]:

  [dk*K1-d0<a]  # stack:                4 1
   d            # duplicate top:        4 4 1
    k           # pop & set precision:  4 1
     *          # multiply              4
      K         # push precision        4 4
       1        # push 1                1 4 4
        -       # subtract              3 4
         d0<a   # if top > 0 exec content of register a, namely [string]
                # output on stack:      24
Source Link
ბიმო
  • 16.9k
  • 2
  • 41
  • 104

dc, 23 bytes

1r[dk*K1-d0<a]dsax_1*+p

Try it online or verify 0-125!

Explanation

1r[dk*K1-d0<a]dsax_1*+p  # input on stack, eg:     4
1                        # push 1:                 1 4
 r                       # reverse top two:        4 1
  [dk*K1-d0<a]           # push [string]:          [string] 4 1
              dsa        # copy top to register a: [string] 4 1
                 x       # exec top*               0 24
                  _1     # push -1:                -1 0 24
                    *    # multiply:               0 24
                     +   # add:                    24
                      p  # print top element

# first exec of [string]:

  [dk*K1-d0<a]  # stack:                4 1
   d            # duplicate top:        4 4 1
    k           # pop & set precision:  4 1
     *          # multiply              4
      K         # push precision        4 4
       1        # push 1                1 4 4
        -       # subtract              3 4
         d0<a   # if top > 0 exec content of register a, namely [string]

In case of 0 after the exec part (*), the stack will be -1 0:

x       # exec top*               -1 0
 _1     # push -1:                -1 -1 0
   *    # multiply:               1 0
    +   # add:                    1