[Question]
      [
Given a pattern (string or array format) of Bits :
`[0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1]`
The tasks is to replace any number of consecutive 1-Bits with an ascending number sequence starting at 1.
**Input**
* Pattern (can be received as an string or array) Example:
	+ String: `1001011010110101001`
	+ Array: `[1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1]`
**Output**
* Ascending number sequence (can be returned as an string or array) Example:
	+ String: `1 0 0 1 0 1 2 0 1 0 1 2 0 1 0 1 0 0 1`
	+ Array: `[1, 0, 0, 1, 0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 0, 1, 0, 0, 1]`
**Rules**
* *(only apply for strings)* Input wont contain spaces between `1` and `0`
* Assume Input `length > 0`
* *(only apply for strings)* Output is separated by space (use any other separator if you need as long as is not a number or a letter from the alphabet)
**Example:**
```
Given [0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1]
Output [0,1,2,3,0,1,2,0,0,0,1,2,3,4,5,6]
--------------------------------------------------------------------------
Given 0110101111101011011111101011111111
Output 0 1 2 0 1 0 1 2 3 4 5 0 1 0 1 2 0 1 2 3 4 5 6 0 1 0 1 2 3 4 5 6 7 8
---------------------------------------------------------------------------
Given 11111111111101
Output 1 2 3 4 5 6 7 8 9 10 11 12 0 1
```
---
Winning criteria: Codegolf

[Answer]
## [Retina](https://github.com/m-ender/retina/wiki/The-Language), 14 bytes
```
rv`0|(1)+
$#1¶
```
[Try it online!](https://tio.run/##K0otycxLNPz/v6gswaBGw1BTm0tF2fDQtv//DQwNDQwNDICUIZgFIhBsCAAA "Retina – Try It Online")
[Answer]
# C (gcc), ~~57~~ ~~52~~ 51 bytes
```
f(a,l,c,i)int*a;{for(c=i=0;i<l;)a[i++]=c=a[i]*-~c;}
```
Port of [Arnauld's JavaScript answer](https://codegolf.stackexchange.com/a/167576/79343), modifies the array in-place. Try it online [here](https://tio.run/##XU5BCoMwEDzrK4JQMCbSeI55iXgIQe2CjSW1h1bSr6cbmxZaWDazk5lhTD0ZE8JYaj5zw4GCXSstt3FxpVGghIR2llR3wFivjELQV/XTSB9QSc4abEnJlmfx0s7pe9cTRbaGE7FP89nf@SPF747Ay3fePNhpPWHcFR7Dgh1jPj2mCxUUhYnmSb1TWD76Aa1C4tOmT8SM7XWzi0PFWBYHIAVPzaGPbp9nblhvzqI39@EF).
[Answer]
## Java, 65 bytes
`void a(int[]q){for(int i=1;i<q.length;i++)q[i]+=q[i]>0?q[i-1]:0;}`
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~11~~ 10 bytes
```
0w"@+@*t]x
```
[Try it online!](https://tio.run/##y00syfn/36BcyUHbQasktuL//2gDHUMwNICSBjowETCMBQA "MATL – Try It Online")
*(-1 byte thanks to Giuseppe)*
The obvious "accumulate y(x+y) over the array" approach.
### 16 bytes
```
n:G~f!-tO<YYw(X<
```
[Try it online!](https://tio.run/##y00syfn/P8/KvS5NUbfE3yYyslwjwub//2gDHUMwNICSBjowETCMBQA "MATL – Try It Online")
Longer, more matrix-y approach: get the overall index, broadcast-subtract the indices of all zeros, and take the difference from the index of the nearest zero.
[Answer]
## [Zig](https://github.com/ziglang/zig), 65 bytes
```
fn f(b:[]u8)[]u8{for(b)|_,i|{if(i>0)b[i]+=b[i-1]*b[i];}return b;}
```
Expanded version
```
fn f(b:[]u8) []u8 {
    // Foreach loop where only index is used.
    for(b) |_,i| {
        // First value is always going to be 0 or 1,
        if(i > 0)
            // b[1] will either be 0 or 1,
            // so this is basically an if statement
            // that we can use to reset the count.
            b[i] += b[i-1] * b[i];
    }
    return b;
 }
```
I would add a *Try it online!*, but their compiler seems to lack some crucial language features. (Language still being in development and all that)
And I am not going to attempt to make it compatible through trial and error.
But you can copy paste this into [Zig playground](https://zig-play.dev/) (Confirmed to work as of writing this post)
```
const std = @import("std");
fn f(b:[]u8)[]u8{for(b)|_,i|{if(i>0)b[i]+=b[i-1]*b[i];}return b;}
pub fn main() anyerror!void {
    var bits = [_]u8{0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1};
    var array = f(bits[0..]);
    try std.io.getStdOut().writer().print("{any}\n", .{array});
}
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
Ġv¦f
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLEoHbCpmYiLCIiLCJbMCwxLDEsMSwwLDEsMSwwLDAsMCwxLDEsMSwxLDEsMV0iXQ==)
-6 thanks to Lyxal.
```
Ġ    # Group consecutive identical elements
 v¦  # Take the cumulative sum of each
   f # Flatten the result
```
[Answer]
# [Thunno](https://github.com/Thunno/Thunno), \$ 6 \log\_{256}(96) \approx \$ 4.94 bytes
```
zy.z(S
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72sJKM0Ly9_wYKlpSVpuhbLqir1qjSCIRyo2IKbitEGOoZgaAAlDXRgImAYC1EJAA)
#### Explanation
```
zy      # Group by consecutive
  .     # Apply to each:
   z(   #  Cumulative sums
     S  # Flatten
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~11~~ 9 bytes
```
(*/+\|,)\
```
[Try it online!](https://ngn.codeberg.page/k#eJxljEsKgDAMRPc5xZBNWxVt/FTt3hu4dN1TiGe3rSBFJ5BMHsMEr6uuPs7GHES7b5XSbEVsnKR8H/uyKCYALIWssKHNawtBj7QfN2DEVPwldb+cw4wldX8QVkjMCSQ3GKLtCmqnG8uDITk=)
-2 bytes thanks to ovs
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ŒgJ€F×
```
[Try it online!](https://tio.run/##y0rNyan8///opHSvR01r3A5P////f7SBjiEYGkBJAx2YCBjGAgA "Jelly – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 15 bytes
```
.(?<=(1*))
$.1
```
[Try it online!](https://tio.run/##K0otycxL/P9fT8PexlbDUEtTk0tFz1Dh/39DAwNDA0NDOAHkcgGZYK4BiAEEClwwFYZwlQg2BHAZIgEDQwA "Retina 0.8.2 – Try It Online") Link includes test cases. Alternative version, also 15 bytes:
```
.(?<=(1)*)
$#1
```
[Try it online!](https://tio.run/##K0otycxL/P9fT8PexlbDUFNLk0tF2VDh/39DAwNDA0NDOAHkcgGZYK4BiAEEClwwFYZwlQg2BHAZIgEDQwA "Retina 0.8.2 – Try It Online") Link includes test cases Explanation:
```
.
```
Match the 0s and 1s.
```
(?<=(1*))
(?<=(1)*)
```
Count the number of 1s from the current digit backwards. The first one counts by capturing the run of 1s as a subtring, while the second one counts the number of times the 1 was captured.
```
$.1
$#1
```
Replace the digit with the number of 1s, either via the length of the capture or by the number of captures as appropriate.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 9 bytes
```
t.u*YhNQZ
```
[Verify all the test cases](https://pyth.herokuapp.com/?code=Q%0At.u%2AYhNQZ&test_suite=1&test_suite_input=%5B0%2C1%2C1%2C1%2C0%2C1%2C1%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%5D%0A%5B0%2C1%2C1%2C0%2C1%2C0%2C1%2C1%2C1%2C1%2C1%2C0%2C1%2C0%2C1%2C1%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C1%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%5D%0A%5B1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C1%5D&debug=0)
```
t.u*YhNQZ   Implicit: Q=eval(input())
 .u    QZ   Cumulative reduce over Q, starting value 0
     hN       Increment the current value
   *Y         Multiply by the next value
t           Remove 1st element of list, implicit print
```
[Answer]
# racket, 107 bytes
```
(λ(i)(let c((x i)(z 0))(if(empty? x)'()(if(= (car x)1)(cons(+ 1 z)(c(cdr x)(+ 1 z)))(cons 0(c(cdr x)0))))))
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 78 bytes
```
(<>)<>([]){{}{{}<>(({})())<>}([]){{}(<>)<>}{}([])}{}<>([]){{}({}<>)<>([])}<>{}
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X8PGTtPGTiM6VrO6uhaIgGyN6lpNDU2gaC1UGKKmthrMrwWrgUqA2FDtQFZ17f//BgqGQGgAxTCI4COLYqoDQwA "Brain-Flak – Try It Online")
Readable version:
```
(<>)<>
([])
{
    {}
    {
        {}<>(({})())<>
    }
    ([])
    {
        {}(<>)<>
    }
    {}
    ([])
}{}<>
([])
{
    {}({}<>)<>([])
}<>{}
```
[Answer]
# [Julia 0.6](http://julialang.org/), 28 bytes
```
t->(x=0;[(x=(x+y)y)for y=t])
```
[Try it online!](https://tio.run/##yyrNyUw0@5@mYPu/RNdOo8LWwDoaSGpUaFdqVmqm5RcpVNqWxGr@z00s0Cgoyswrycl71DEjTUdBI9pAxxAMDaCkgQ5MBAxjdTQ1Ff4DAA "Julia 0.6 – Try It Online")
[Answer]
# C++, ~~46~~ ~~45~~ 41 bytes
Generic lambda, any int [container](https://en.cppreference.com/w/cpp/named_req/Container).
```
[](auto&a){int p=0;for(int&i:a)p=i*=p+i;}
```
Saved a byte with the `*=` operator, saved 4 bytes by removing unneeded braces and parenthesis.
Note: The `p+i` part can be replaced with `p+1` or `++p`, I'm not sure why I did `p+i` but it wouldn't save any bytes to change it.
Old:
```
[](auto&a){int p=0;for(int&i:a){p=i=i*(p+i);}}
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 52 51 bytes
Thanks to ceilingcat for the suggestion.
```
c;f(char*i){for(;*i;printf("%d ",c=~c*(48-*i++)));}
```
[Try it online!](https://tio.run/##PYxBCoMwEEX3nmKwFDJRi4EuCmm9SOlCRqMDNZZU3Yi9eppY6J/Ff8yDT0VH5A9s6Tk3LVzfU8Pjqa88aSOor51kXM3ohJasX47tZER6bCDN6fYhKc6XQnKWIaLefLAw1GxFhNp1lMcFkDLwgrAmAGxEFJVC2Gm5qwfqJBjXTrOzUOpk875UqgwXs/cP/7@QLw "C (gcc) – Try It Online")
[Answer]
# [Arturo](https://arturo-lang.io), 22 bytes
```
$=>[0map&=>[<=&*<=1+]]
```
[Try it](http://arturo-lang.io/playground?RC2677)
```
$=>[        ; a function, assign input to &
    0       ; push 0
    map&=>[ ; map over input, assign current elt to &
        1+  ; increment tos
        <=  ; dup
        &*  ; multiply by current elt
        <=  ; dup
    ]       ; end map
]           ; end function
```
[Answer]
# TI-Basic, 25 bytes
```
Prompt B
For(I,1,dim(⁻B
⁻B(I)(Ans+1
Disp Ans
End
```
Input is taken as a list. Output is as numbers separated by newlines.
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 2.5 bytes (5 nibbles)
```
=\$+*
```
```
=\$+*       # full function
=\$+*$@$    # (with implicit arguments shown):
=\          # scan from left over
  $         # input
            # with function:
   +        #   add
       $    #   each element
            #   to
    *       #   product of
     $      #   each element
            #   and
      @     #   result so far
```
[![enter image description here](https://i.stack.imgur.com/yC3tt.png)](https://i.stack.imgur.com/yC3tt.png)
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 6 bytes
```
(×+⊢)`
```
[Try it at BQN online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgKMOXK+KKoilgCgpGIOKfqDAsMSwxLDEsMCwxLDEsMCwwLDAsMSwxLDEsMSwxLDHin6k=)
### Explanation
Port of [Dominic van Essen's Nibbles answer](https://codegolf.stackexchange.com/a/258990/16766).
```
(×+⊢)`
(    )`  Left scan on this function:
  +       Add
   ⊢      each element to
 ×        the product of the element and the previous intermediate value
```
[Answer]
# [KamilaLisp v0.2](https://github.com/kspalaiologos/kamilalisp), 14 (APL SBCS)
```
$(⍀.←[+ * #1])
```
Equivalent to `$(scanl1[+ * #1])`.
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 4 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
ġıż×
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faGm0UrBS7IKlpSVpuhYrjiw8svHonsPTlxQnJRdDBRfcVIw20DEEQwMoaaADEwHDWIhKAA)
#### Explanation
```
ġıż×  # Implicit input
ġ     # Group consecutive items
 ı    # Map over this list of lists:
  ż   #  Push [1..length] without popping
   ×  #  Multiply the two lists elementwise
      # Implicit output, summed (flattened)
```
[Answer]
# Python 2, ~~52~~ 46 bytes
```
f=lambda x,y=1:x and[y*x[0]]+f(x[1:],y*x[0]+1)
```
Saved 6 bytes thanks to Jo King and Rod!
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 75 bytes
---
**Golfed** [Try it online!](https://tio.run/##jZFNS8QwEIbv@RVDEUlot6R6M20vC4JSEPTgYd1DqOnugKTSpHgo@e01Xdu1hd3V4YUZ5uOZMCnNqjTY37e6TB@0vb3ZbCMYgxwqyHqZ5V1VNxS1BcwSgamMC6V3di8wDBlWVG5wlWxzfu0D79jgsp9kmIhG2bbRIIUTfYHGpkc6AW9WGbuWRhnIQKsvWLRQBt2ha7ChOhagAx5BMonPAh4tSqPARX9x@BKVnMmfgJ@f/f/2y@IziBOE@P9QstzTI2m6IqCeXXS63rrWpv5Q8WuDVhWoFYWrwM9@tvYOug66F9ug3sWPNWoaROA1QZgD5970U2svNFf09wFsnAiACeIImXY/K/l@WM1E/w0 "C# (Visual C# Interactive Compiler) – Try It Online")
```
a=>{for(int i=1;i<a.Length;i++)if(a[i-1]>0&a[i]>0)a[i]=a[i-1]+1;return a;};
```
---
**Ungolfed**
```
a => {
    for( int i = 1; i < a.Length; i++ )
        if( a[ i - 1 ] > 0 & a[ i ] > 0 )
            a[ i ] = a[ i - 1 ] + 1;
    return a;
};
```
---
**Full code**
```
using System;
namespace Namespace {
    class Program {
        static void Main( String[] args ) {
            Func<Int32[], Int32[]> f = a => {
                for( int i = 1; i < a.Length; i++ )
                    if( a[ i - 1 ] > 0 & a[ i ] > 0 )
                        a[ i ] = a[ i - 1 ] + 1;
                return a;
            };
            List<Int32[]>
                testCases = new List<Int32[]>() {
                    new Int32[] { 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 },
                    new Int32[] { 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
                    new Int32[] { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
                };
            foreach( Int32[] testCase in testCases ) {
                Console.WriteLine( $"{{ {String.Join(", ", testCase)} }}\n{f( testCase )}" );
            }
            Console.ReadLine();
        }
    }
}
```
---
**Releases**
* **v1.0** - `75 bytes` - Initial solution.
---
**Notes**
* None
[Answer]
# [Dodos](https://github.com/DennisMitchell/dodos), 152 bytes
```
	_ b _ F >
b
	dab
t
	dot
(
	t b
	t
X
	X dip
<
	b X (
/
	<
	< b
0
	t 0 b
>

	0
.
	dip <
	< b
	t b
x
	x .
H
	b b x >
	b
G
	t H /
	b b
F
	<
	F G
_
	_ b
	<
```
[Try it online!](https://tio.run/##PU4xDoQwDJvjV3hkgt6OGAtP6IaIujAV6Tr097m0QqdIiWPHSXLJ5WsmJ5UnIzcoJF@K6qVUTJBKpyoSJDHfD1aIMnHCAnG8uhz6VHCwQSABs5vvh686NjRI44yjm5XND4li79rBZZCIY1/kjhP9IW/NLNhnRHhz@DMjfg "Dodos – Try It Online")
[Answer]
# Python 2.7, 217 Bytes
```
def f(d):
    c = 0
    r = []
    for e in d:
        if e == 1:
            r.append(1 + c)
            c += 1
        else:
            c = 0
            r.append(0)
    return r
```
I'm new so.
[Answer]
# [Kotlin](https://kotlinlang.org), 73 bytes
```
var i=0
readLine()?.forEach{(it-48).toInt().let{c->i=i*c+c;print("$i ")}}
```
[Try it online!](https://tio.run/##y84vycnM@59WmqeQm5iZp5FYlF5speBYVJRYaRNcUpSZl26nqVD9vyyxSCHT1oCrKDUxxSczL1VD014vLb/INTE5o1ojs0TXxEJTryTfM69EQ1MvJ7WkOlnXLtM2UytZO9m6AGhIiYaSSqaCkmZt7f/a/waGhgZACAJgGsKEiwEBAA "Kotlin – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, ~~22~~ 20 bytes
*-2 bytes thanks to @DomHastings*
```
s/./$i=$&*++$i.$"/ge
```
[Try it online!](https://tio.run/##K0gtyjH9/79YX09fJdNWRU1LW1slU09FST899f9/A0NDAyAEATANYcLFgOBffkFJZn5e8X9dX1M9oPh/3QIA "Perl 5 – Try It Online")
**Method:**
Replace each character with itself multiplied by the incremented value of `$i`, then store that value back in `$i`. Thus, `$i` starts at 0 (`undef`) and gets reset to 0 every time the character in the bit string is a 0.
Finally, append a space to the result of the above step to make the output format correct.
[Answer]
# Lua, ~~63~~ 54 bytes
```
function f(j)for i=2,#j do j[i]=j[i]*(j[i-1]+1)end end
```
Written by Jo King.
[Try it online!](https://tio.run/##NYZBCoMwEADvecViL7vtWkzveYl4SKOBBNmUJZ7Et6daKMMMs26@tbhJqKkIRMwUi0JyL75lmAvkMU3uyh3P9nZ6WFpkhtOm4GC3PLD9MfzvMCaikjEfTVKx@ve6PEOR4Csqd9wRtS8 "Lua – Try It Online")
---
### Explanation
```
function f(j) -- declares the function 'f' that will receive a variable 'j' (we know it's a table)
  for i=2,#j do -- from 2 to the number of elements in j
    j[i]=j[i]*(j[i-1]+1) -- change the current element of j to itself
              (j[i-1]+1) -- multiplied by the one before it plus one
  end
end
```
Original (invalid) in expanded form:
```
for i=2,#input do -- a loop that goes from 2 to the number of elements in the input table
  if input[i] == 0 then -- if the element at 'i' is 0
    input[i] = 0 -- then keep it as 0
  else
    input[i] = input[i-1]+1 -- change it to the element that comes before + 1
  end
end
```
Feel free to ask or suggest anything!
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), 37 bytes
```
[](auto&a){for(int&i:a)i*=*(&i-1)+1;}
```
[Try it online!](https://tio.run/##tVDBboMwDL3nK6xOqpJCV3IFirQ/2G2HtocopJ0lmqAQehhiv85SCkKl1XaaffGz33u2LMtyfZKye0EtizpXkKKpnFXinJGpd1HSGZsRstl8qKIIwX1iBaZ2Ze1AGk/xUBsHJ1McVQ7CgSgKQi4Gcyitkaqq3nT@blE7Wrk8jm@OqccZCAYNAR/9RHpbSFNY7DVAs7iWYhcdkp5xNJZ6DeCWJ5iK1wq/FGVJECCbqcNBiYPyftru9eLWF7UzcNx2uwO9lkvBmmHJEmPBcLVd0SWuOQt40nbDFVSwZ67f2f/e2xJyNTsL1HT82fy7DQ@jkPcZ9dUNRe1w8QN/Yo@asdPnH7ppA5/hO5cH3u/ePHye0aSxytVWQ@S/0v0A "C++ (gcc) – Try It Online")
---
A lambda function which works with any int container supporting range-based for loops.
]


[Question]
      [
Output this exact text:
```
1                i
12              hi
123            ghi
1234          fghi
12345        efghi
123456      defghi
1234567    cdefghi
12345678  bcdefghi
123456789abcdefghi
12345678  bcdefghi
1234567    cdefghi
123456      defghi
12345        efghi
1234          fghi
123            ghi
12              hi
1                i
```
A single trailing newline is acceptable, but no other formatting changes are allowed.
### Rules and I/O
* No input
* Output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963).
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.

[Answer]
# C, ~~87~~ ~~85~~ ~~81~~ 80 bytes
```
j;main(i){for(;++i<19;)for(j=19;j--;)putchar(j?j<i^j<20-i?32:106-j-j/10*39:10);}
```
[Try it online!](https://tio.run/##FchbCoAgEEDR7Wgy5AMCG8OdBCJUM9CDqK9o7WZ/99wMc86lMK6JNkHymfZToFIUjEf5g4daDIDyuK@8pHoiBxo5WA0Une2N7oCBW6Mb56skvqV8 "C (gcc) – Try It Online")
### Explanation
```
j; // same as int j;
main(i){ // same as int main(int i){, where i = argc (1 with no arguments)
  for(;++i<19;) // loop over rows, i = 2..18
    for(j=19;j--;) // loop over chars, j = 19..0
      putchar(j?j<i^j<20-i?32:106-j-j/10*39:10); // output characters:
      //      j?                           :10 // on last char (j=0), output \n
      //        j<i                            // check for top/left half
      //            j<20-i                     // check for bottom/left half
      //           ^                           // 1 if only one half matched
      //                  ?32:                 // if so, output space
      //                      106              // char code for j
      //                         -j            // get desired letter
      //                           -j/10*39    // subtract 39 for j>9 (numbers)
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 73 bytes
```
i=9
exec"i-=1;a=abs(i);print'123456789'[:9-a]+'  '*a+'abcdefghi'[a:];"*17
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9PWkiu1IjVZKVPX1tA60TYxqVgjU9O6oCgzr0Td0MjYxNTM3MJSPdrKUjcxVltdQUFdK1FbPTEpOSU1LT0jUz060SrWWknL0Pz/fwA "Python 2 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 64 bytes
```
for(i in abs(8:-8))cat(intToUtf8(c(57-8:i,32*!!-i:i,97+i:8,13)))
```
[Try it online!](https://tio.run/##K/r/Py2/SCNTITNPITGpWMPCStdCUzM5sUQjM68kJD@0JM1CI1nD1FzXwipTx9hIS1FRNxPIsjTXzrSy0DE01tTU/P8fAA "R – Try It Online")
* -3 bytes thanks to @Giuseppe
* -5 bytes thanks to @J.Doe
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 15 bytes
```
A9£Sāì9LÂì×ζRû»
```
[Try it online!](https://tio.run/##ASIA3f8wNWFiMWX//0E5wqNTxIHDrDlMw4LDrMOXzrZSw7vCu/// "05AB1E (legacy) – Try It Online")
-2 thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen).
[Answer]
# [Python 2](https://docs.python.org/2/), 80 bytes
```
j=i=1
exec"print'123456789'[:i]+'  '*(9-i)+'abcdefghi'[-i:];i+=j;j-=2*(i>8);"*17
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P8s209aQK7UiNVmpoCgzr0Td0MjYxNTM3MJSPdoqM1ZbXUFBXUvDUjdTU1s9MSk5JTUtPSNTPVo30yrWOlPbNss6S9fWSEsj085C01pJy9D8/38A "Python 2 – Try It Online")
[Answer]
# QBasic, 72 bytes
Based on [Taylor Scott's submission](https://codegolf.stackexchange.com/a/167477/16766).
```
FOR y=-8TO 8
z=ABS(y)
?"123456789abcdefghi";
LOCATE,10-z
?SPC(2*z)"
NEXT
```
### Basic explanation
On each line, we print the full string `123456789abcdefghi`. Then we *go back* and overwrite part of it with spaces.
### Full explanation
With code slightly ungolfed:
```
FOR y = -8 TO 8           ' Loop for 17 rows
 z = ABS(y)               ' z runs from 8 to 0 and back to 8
 ? "123456789abcdefghi";  ' Print the full string and stay on the same line (important!)
 LOCATE , 10-z            ' Go back to column 10-z on that line
 ? SPC(2*z); ""           ' Print 2*z spaces
                          ' (SPC keeps the cursor on the same line unlesss you print
                          ' something after it, so we'll use the empty string)
NEXT                      ' Go to the next y value
```
[Answer]
# T-SQL, 108 bytes
```
DECLARE @ INT=8a:
PRINT STUFF('123456789abcdefghi',10-abs(@),2*abs(@),SPACE(2*abs(@)))
SET @-=1IF @>-9GOTO a
```
Returns are for readability only.
Tried lots of other variations, including number tables, this was the shortest.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 20 bytes
```
9LJη.BA9£.sí.Bí)øJû»
```
[Try it online!](https://tio.run/##ASUA2v8wNWFiMWX//zlMSs63LkJBOcKjLnPDrS5Cw60pw7hKw7vCu/// "05AB1E – Try It Online")
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 13 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
９Ｒ［］ｚ９ｍ±［］±＋─
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjE5JXVGRjMyJXVGRjNCJXVGRjNEJXVGRjVBJXVGRjE5JXVGRjREJUIxJXVGRjNCJXVGRjNEJUIxJXVGRjBCJXUyNTAw,v=3)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 20 bytes
```
9Æ9Ç>YÃê1 Ë?S:°EsH
ê
```
[Japt Interpreter](https://ethproductions.github.io/japt/?v=1.4.5&code=OcY5xz5Zw+oxIMs/UzqwRXNICuo=&input=LVI=)
Output as an array of arrays of characters. The `-R` flag isn't necessary to work, it just makes the output look nicer.
Explanation:
```
9Æ9Ç                    create a 9x9 2D array
    >YÃ                 fill bottom left triangle with "false", upper right with "true"
       ê1               mirror horizontally
          Ë?S           replaces "true" with a space
             :°EsH      replaces "false" with the horizontal index + 1 converted to base 32
                  \n    Store the result in U (saves bytes by not closing braces)
                    ê   palindromize vertically
```
[Answer]
# PowerShell 5.1, ~~70~~ ~~69~~ ~~64~~ 57 Bytes
Thanks Mazzy for -7 bytes
```
1..9+8..1|%{-join(1..$_+'  '*(9-$_)+' ihgfedcba'[$_..1])}
```
Turns out gluing it together manually saves a byte. Making it all one mega-join also saves 5 more. ~~Also works by turning a range of ints into a char[] to get the a-i.~~ Using a range over the actual letters is 5 bytes better.
[Answer]
# [Julia 1.0](http://julialang.org/), 73 bytes
```
[1:9;8:-1:1].|>i->println(join(1:9)[1:i]*" "^(18-2i)*"abcdefghi"[10-i:9])
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/P9rQytLawkrX0MowVq/GLlPXrqAoM68kJ08jKz8zTwMoqwlUkhmrpaSgFKdhaKFrlKmppZSYlJySmpaekakUbWigm2llGav5/z8A "Julia 1.0 – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 47 bytes
```
9l$lRtH2$PhO18Y"yPvv1=49:57 97:105h19T3$X"32b(c
```
[Try it online!](https://tio.run/##y00syfn/3zJHJSeoxMNIJSDD39AiUqkyoKzM0NbE0srUXMHS3MrQwDTD0DLEWCVCydgoSSP5/38A "MATL – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 14 bytes
```
9ʀṘǔmkrf*ꜝøṗ↵§
```
[Try it online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCI5yoDhuZjHlG1rcmYq6pydw7jhuZfihrXCpyIsIiIsIiJd)
**Explanation**
A transposition approach.
```
9ʀ             # range from 0 to 9 inclusive
  Ṙ            #  reversed
   ǔ           #  rotated right (last item goes to first)
    m          #  and concatenated with its reverse
     kr        # string of digits, lowercase alphabet, and uppercase alphabet
       f       #  into a list of characters
        *      # repeat (vectorises)
         ꜝ     # remove empty strings in the list
          øṗ   # palindromise each item, center, and join by newlines
            ↵  # split on newlines
             § # vertically join
```
[Answer]
# Japt, ~~24~~ 19 bytes
Returns an array of lines
```
9õ Ôê1 Ëç°TsH)êÃû y
```
[Test it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=OfUg1OoxIMvnsFRzSCnqw/sgeQ&input=LVI)
```
9õ Ôê1 Ëç°TsH)êÃû y
9õ                      :Range [1,9]
   Ô                    :Reverse
    ê1                  :Mirror
       Ë                :Map
        ç               :  Repeat
         °T             :    Prefix increment T (initially 0)
           s            :    Convert to base
            H           :    32
             )          :  End repeat
              ê         :  Palindromise
               Ã        :End map
                û       :Centre pad each with spaces to the length of the longest
                  y     :Transpose
```
([It did indeed, 4 year ago Shaggy, it did indeed](https://codegolf.stackexchange.com/questions/167405/alpha-numerical-bowtie/254376#comment404603_167407)!)
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 18 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
â4+╤jo♂▐▀3bkWíæß╝╖
```
[Run and debug it](https://staxlang.xyz/#p=83342bd16a6f0bdedf33626b57a191e1bcb7&i=&a=1)
Explanation:
```
9R$|[|<Va17T|]r|>\|pm Full program
9R$                   Produce "123456789"
   |[|<               Left-aligned prefixes (["1        ", "12       ", ...])
       Va17T          Produce "abcdefghi"
            |]        Suffixes (["abcdefghi", "bcdefghi", ...])
              r|>     Reverse and left-align (["        i", "       hi", ...])
                 \    Zip both arrays (["1                i", "12              hi", ...])
                  |p  Palindromize array
                    m Map over array, printing each with a newline
```
[Answer]
# JavaScript (ES6), 76 bytes
```
f=(x=y=0)=>y<17?(x>y^x++<17-y?x.toString(36)+[`
`[x%=18]]:' ')+f(x||!++y):''
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zVajwrbS1kDT1q7SxtDcXqPCrjKuQlsbyNattK/QK8kPLinKzEvXMDbT1I5O4EqIrlC1NbSIjbVSV1DX1E7TqKipUdTWrtS0Ulf/n5yfV5yfk6qXk5@ukaahqfkfAA "JavaScript (Node.js) – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 30 bytes
```
(⊢⍪1↓⊖)(↑,\1↓⎕d),⌽↑,\⌽819⌶9↑⎕a
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM9/b/Go65Fj3pXGT5qm/yoa5qmxqO2iToxYF7f1BRNnUc9e8EiQNrC0PJRzzZLIBcolQjS/T8dAA "APL (Dyalog Unicode) – Try It Online")
`↑` convert to a matrix (auto pads with spaces)
* `,\` the prefixes of
* `1↓` the first element dropped from
* `⎕d` this string `'0123456789'`
* This gives the character matrix
```
1
12
123
1234
12345
123456
1234567
12345678
123456789
```
`,` concatenated with
* `⌽` the reversed
* `↑` matrixified
* `,\` prefixes of
* `⌽` the reversed
* `819⌶` and lowercased
* `9↑` first 9 elements of
* `⎕a` this string `'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
* This gives the character matrix
```
        i
       hi
      ghi
     fghi
    efghi
   defghi
  cdefghi
 bcdefghi
abcdefghi
```
and on this result
```
1                i
12              hi
123            ghi
1234          fghi
12345        efghi
123456      defghi
1234567    cdefghi
12345678  bcdefghi
123456789abcdefghi
```
perform the following train `(⊢⍪1↓⊖)`
`⊢` the right argument
`⍪` concatenated vertically with
`1↓` the first row dropped from (this avoids the repeating of the middle row)
`⊖` the right argument reversed vertically
---
Other solutions
### 33 bytes
```
(⊢⍪1↓⊖)(↑,\⍕¨q),⌽↑,\⎕ucs 106-q←⍳9
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM9/b/Go65Fj3pXGT5qm/yoa5qmxqO2iToxj3qnHlpRqKnzqGcvhN83tTS5WMHQwEy38FHbhEe9my1Buv@nAwA "APL (Dyalog Unicode) – Try It Online")
### 33 bytes
```
(⊢⍪1↓⊖)(↑,\⍕¨q),⌽↑,\⌽⎕ucs 96+q←⍳9
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM9/b/Go65Fj3pXGT5qm/yoa5qmxqO2iToxj3qnHlpRqKnzqGcvhA@k@6aWJhcrWJppFz5qm/Cod7MlSP//dAA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~22~~ 17 bytes
```
Ｇ↗↓←⁹β←Ｇ↖↓⁹⭆χι‖Ｏ↓
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8gP6cyPT9Pwyq0ICgzPaNER8HKJb88D0j5pKYBeZY6Ckma1ly@@WWpGmAhIAdJD0QRVAtQbXBJUWZeum9igYahgY5CpiZQdVBqWk5qcol/WWpRDlAcrFbT@v///7plOQA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｇ↗↓←⁹β
```
Draw a lower right triangle and fill it using the lowercase alphabet. (The fill is based on tiling the plane with the alphabet and then copying the drawn area.)
```
←
```
Move left to draw the numeric triangle.
```
Ｇ↖↓⁹⭆χι
```
Draw a lower left triangle and fill it using the digits. (Since the triangle is drawn to the left of the origin, the digits are taken right-justified, so only the digits 1 to 9 get used.)
```
‖Ｏ↓
```
Reflect to complete the bottom half.
[Answer]
# [V](https://github.com/DJMcMayhem/V), ~~25~~, 21 bytes
```
¬19¬ai8ñHÄ/á
r ge.YGp
```
[Try it online!](https://tio.run/##K/v//9AaQ8tDaxIzLQ5v9Djcon94IVeRQnqqXqR7wf//AA "V – Try It Online")
2-4 bytes saved thanks to nmjcman101!
Hexdump:
```
00000000: ac31 39ac 6169 38f1 48c4 2fe1 0a72 2067  .19.ai8.H./..r g
00000010: 652e 5947 70                             e.YGp
```
[Answer]
# [J](http://jsoftware.com/), 44 bytes
```
(m]\u:49+i.9),.(m=.,}.@|.)]\&.(|."1)u:97+i.9
```
[Try it online!](https://tio.run/##y/r/PzU5I18jNzam1MrEUjtTz1JTR08j11ZPp1bPoUZPMzZGTU@jRk/JULPUytIcJP//PwA "J – Try It Online")
I tried to generate numerically a mask of 1 and zero to use for indexing, but the cost of getting rid of the extra row was high and I gave up:
```
   (9-.~i.18){0<:-/~(,|.)i.9
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1
1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1
1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1
1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1
1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1
1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1
1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
```
[Answer]
## [Perl 5](https://www.perl.org/) + `-M5.010`, 49 bytes
```
say 1..9-abs,"  "x abs,(a..i)[-9+abs..-1]for-8..8
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVLBUE/PUjcxqVhHSUFBqUIBxNJI1NPL1IzWtdQG8vT0dA1j0/KLdC309Cz@//@XX1CSmZ9X/F/X11TPwNAAAA "Perl 5 – Try It Online")
[Answer]
# [QBasic](https://archive.org/details/msdos_qbasic_megapack "QBasic Emulator"), 87 bytes
An anonymous function that takes no input and outputs to the console.
```
For y=-8To 8:z=Abs(y):a$="123456789abcdefghi":?Mid$(a$,1,9-z)Spc(2*z)Mid$(a$,10+z):Next
```
This answer is technically a polyglot, and will function in VBA
[Answer]
# [Befunge-93](https://github.com/catseye/Befunge-93), 314 308 bytes
```
<p0+3*67p0+4*77p0+3*77p0-7*88p0-6*88"#v#v>"
"i        "11g1-21p56+1g1+56+1p28*1g1+28*1p  ^       >25*
"        1"92g1+82p56+2g1-56+2p28*2g1-28*2p91g00g`#v_^   >
"ihgfedcba "93p26*3g1-26*3p">^"88*7-0p88*7-4pv     >25*
"987654321 "14p26*4g1+26*4p26*4g12g`#v_            ^
                             >:#,_@#:<
```
[Try it online!](https://tio.run/##fY7BDoIwEETvfEWzvRWb0FLaQkjjl4CiWL2Yvcjv4y7BhJNzedNkprPT/Pi887yuPVZlrXwgOBXC9mLooGIkeALIRS4JCniJXWBMNtoabHxJrmSgjYo9A4UY9miyjSrgVzTQWspEy01ymsFN9gxsTa6qfJHLyD8kGn3mx3y/TVcBbY3Wq5qjBIQ0QIwq6Ao3OFwOk20MvnG1NXSt457j4wi7t9uIOGgoxD@lTp7Gs@z6df0C "Befunge-93 – Try It Online")
Golfed 6 bytes by placing a `>` with the `p` instruction
[Answer]
## Matlab, 122 bytes
```
function[r]=f,s=[49:57,'a':'i'];r=[];for i=1:9,r=[r;s(1:i),repmat(' ',[1,18-2*i]),s(19-i:18)];end,r=[r;flip(r(1:8,:))];end
```
[Try it Online!](https://tio.run/##JctBCsMgEEDRq2SnlsnC0lId8STiQlKFgVbDxPT6Vsjy8/ht6@mXxyhn3Tq1Gjj6AocPD4vPF4gkUJCIjn2IrjReyGu0MJPdITWSAs77N3UpFgFBgzbr/UZRwVS7Emqjosv1fS3lQ7vk@RlAdcEoUo0/)
[Answer]
# [Deadfish~](https://github.com/TryItOnline/deadfish-), 956 bytes
```
{iiiii}dc{dd}iii{c}cccccc{{i}ddd}iiic{{d}i}dddddc{iiii}dcic{dd}ii{c}cccc{{i}ddd}iicic{{d}i}dddddc{iiii}dcicic{dd}i{c}cc{{i}ddd}icicic{{d}i}dddddc{iiii}dcicicic{dd}{c}{{i}ddd}cicicic{{d}i}dddddc{iiii}dcicicicic{dd}dcccccccc{{i}ddd}dcicicicic{{d}i}dddddc{iiii}dcicicicicic{dd}ddcccccc{{i}ddd}ddcicicicicic{{d}i}dddddc{iiii}dcicicicicicic{dd}dddcccc{{i}ddd}dddcicicicicicic{{d}i}dddddc{iiii}dcicicicicicicic{dd}ddddcc{iiiiii}iiiiiicicicicicicicic{{d}i}dddddc{iiii}dcicicicicicicicic{iiii}cicicicicicicicic{{d}i}dddddc{iiii}dcicicicicicicic{dd}ddddcc{iiiiii}iiiiiicicicicicicicic{{d}i}dddddc{iiii}dcicicicicicic{dd}dddcccc{{i}ddd}dddcicicicicicic{{d}i}dddddc{iiii}dcicicicicic{dd}ddcccccc{{i}ddd}ddcicicicicic{{d}i}dddddc{iiii}dcicicicic{dd}dcccccccc{{i}ddd}dcicicicic{{d}i}dddddc{iiii}dcicicic{dd}{c}{{i}ddd}cicicic{{d}i}dddddc{iiii}dcicic{dd}i{c}cc{{i}ddd}icicic{{d}i}dddddc{iiii}dcic{dd}ii{c}cccc{{i}ddd}iicic{{d}i}dddddc{iiii}dc{dd}iii{c}cccccc{{i}ddd}iiic
```
[Try it online!](https://tio.run/##rZNBDoQgDEVPNIcy/zuZrmfZcHam2uoIiRBUNkB970elcJ74lu/nlbPKMhKhZLKVImEdqlb1mq1tXnY0LngJI4Q/jjM@jFXYcbR4N0zYcPR4NwiUH3F43FBDZuUWQFPfAlj6FdKJ2EMsxU9Hkk811g2SqGNcfegdbv@PWydyuRfG2m6srceuTeta5vwD "Deadfish~ – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 119 bytes
```
import Data.Char
main=putStr$do i<-[-8..8];[chr$if abs j>abs i then j+96-fromEnum(j<0)*38else 32|j<-[-9..9],j/=0]++"\n"
```
[Try it online!](https://tio.run/##Fcw9DsIgGADQ3VN8aTqoCDY2MRBbF/UEjpUBKw0gPw3QzbtjurzxKZG@0tpStJtDzHAXWZCbEnHjhPb9vORnjvUngO7wgCkhlF@GUcVaTyDeCcx1VUNW0oNB7IynGNzDL25ruma3b6m0SUJ7@pk1YIQwfjDHvuEIVS9flfIH "Haskell – Try It Online")
[Answer]
# [Julia 1.0](http://julialang.org/), 54 bytes
```
[8:-1:1;0:8].|>i->print.([1:9-i;" "^2i;'a'+i:'i';"
"])
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/P9rCStfQytDawMoiVq/GLlPXrqAoM69ETyPa0MpSN9NaSUEpzijTWj1RXTvTSj1T3VqJSylW8/9/AA "Julia 1.0 – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~81~~ 79 bytes
```
a=Table[" ",17,18];Do[a[[i;;-i,i]]=a[[1-i;;i-1,i]]=i~IntegerString~35,{i,18}];a
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78H1iamVoSzcVVUJSfbqvxP9E2JDEpJzVaSUFJx9Bcx9Ai1tolPzoxOjrT2lo3UyczNtYWyDHUBXIzdQ3B/Mw6z7yS1PTUouCSosy89DpjU53qTKDO2ljrxP@a1lxcAUDhEgcHB5AVXFyx/wE "Wolfram Language (Mathematica) – Try It Online")
Throws a lot of ignorable errors.
[Answer]
# VBA, 75 bytes
An anonymous VBE immediate window function that takes no input and outputs to the console.
```
For y=-8To 8:z=Abs(y):a="123456789abcdefghi":Mid(a,10-z)=Space(2*z):?a:Next
```
]


[Question]
      [
Consider the following sequence:
```
0 1 3 2 5 4 8 6 7 12 9 10 11 17 13 14 15 16 23 ...
```
Looks pretty pattern-less, right? Here's how it works. Starting with `0`, jump up `n` integers, with `n` starting at `1`. That's the next number in the sequence. Then, append any numbers "skipped" and that haven't been seen yet in ascending order. Then, increment `n` and jump from the last number appended. Repeat this pattern.
So, for example, when we reach `11`, we're at `n=5`. We increment `n` to be `n=6`, jump up to `17`, then append `13 14 15 16` since those haven't been seen yet. Our next jump is `n=7`, so the next element in the sequence is `23`.
### The Challenge
Given input `x`, output the `x`th term of this sequence, the first `x` terms of the sequence, or build an infinite list of the terms of the sequence. You can choose 0- or 1-indexing.
## I/O and Rules
* The input and output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963).
* The input and output can be assumed to fit in your language's native number type.
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.

[Answer]
# JavaScript (ES7), 41 bytes
Returns the **n-th** term of the sequence, 0-indexed.
```
n=>(d=(n--*8-23)**.5)%1?n:'121'[n]^n-~d/2
```
[Try it online!](https://tio.run/##FYtBCsIwEADvfcUSkO4mpDaRQrFGHyIKoWlEKRtpxYvo12N7m4GZh3/7uZ/uz5fmFIYcXWZ3xOCQtZattjuSsmpoY068L4015ZkvV9a/sLU5pgkZHNQdMBzA1CsoRfApAPrEcxqHakw3FB4FqCVSIGgZVonIRF3xzX8 "JavaScript (Node.js) – Try It Online")
## How?
### Main case: \$n > 3\$
The first four terms of the sequence are special, so let's put them aside for now.
For \$n > 3\$, the sequence looks like that:
```
 n  | [4] 5 [6] 7 8 [ 9] 10 11 12 [13] 14 15 16 17 [18] 19 20 21 22 23 [24] 25 26 27 ...
----+------------------------------------------------------------------------------------
a(n)| [5] 4 [8] 6 7 [12]  9 10 11 [17] 13 14 15 16 [23] 18 19 20 21 22 [30] 24 25 26 ...
----+------------------------------------------------------------------------------------
 k  |  2  -  3  - -   4   -  -  -   5   -  -  -  -   6   -  -  -  -  -   7   -  -  - ...
```
We can notice that there are in fact two interleaved sub-sequences:
* Most values belong to the sub-sequence \$A\$ for which we simply have:
$$A(n) = n - 1$$
* Some other values belong to the sub-sequence \$B\$ (highlighted with brackets in the above diagram) whose indices follow the arithmetic sequence **3, 3, 4, 6, 9, 13, 18, 24** ... and for which we have:
$$B(n,k) = n + k - 1$$
where \$n\$ is the index in the main sequence and \$k\$ is the index in the sub-sequence \$B\$.
The indices of \$B\$ in the main sequence are given by:
$$n\_k = \frac{k^2 - k + 6}{2}$$
Given \$n\$, we know that the corresponding term in the main sequence belongs to \$B\$ if \$n\$ is an integer solution of the quadratic equation:
$$x^2 - x + 6 - 2n = 0$$
whose discriminant is:
$$\Delta = 1 - 4(6 - 2n) = 8n - 23$$
and whose positive solution is:
$$x = \frac{1 + \sqrt{\Delta}}{2}$$
We expect \$\sqrt{\Delta}\$ to be an integer. Hence the test:
```
(d = (n-- * 8 - 23) ** .5) % 1
```
### Special cases: \$0 \le n \le 3\$
For \$n < 3\$, the discriminant is negative and taking its square root results in **NaN**. For \$n = 3\$, the discriminant is \$1\$. Therefore, these first four terms of the sequence are considered to belong to the sub-sequence \$B\$.
Should we just apply our standard formula **n - ~d / 2**, we'd get:
$$-\frac 1 2, \frac 1 2, \frac 3 2, 3$$
instead of:
$$0, 1, 3, 2$$
Which is why we XOR these results with \$0,1,2\text{ and }1\$ respectively.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 bytes
```
Θṁṙ_1C+ḣ2tNN
```
[Try it online!](https://tio.run/##yygtzv7//9yMhzsbH@6cGW/orP1wx2KjEj@///8B "Husk – Try It Online")
Outputs as an infinite list. [Here](https://tio.run/##ASEA3v9odXNr///ihpHOmOG5geG5mV8xQyvhuKMydE5O////MjA) is a version that prints the first **N**.
### Explanation
```
Θṁṙ_1C+ḣ2tNN – Full program. Takes no input, outputs to STDOUT.
         tN  – Construct the infinite list of natural numbers, starting from 2.
      +ḣ2    – And append [1, 2] to it. Yields [1,2,2,3,4,5,6,7,8,9,10,11,...].
     C     N – Cut the infinite list of positive integers into pieces of those
               sizes. Yields [[1],[2,3],[4,5],[6,7,8],[9,10,11,12],...].
 ṁ           – Map and flatten the results thereafter.
  ṙ_1        – Rotate each to the right by 1 unit.
               Yields [1,3,2,5,4,8,6,7,12,9,10,11,...]
Θ            – Prepend a 0. Yields [0,1,3,2,5,4,8,6,7,12,9,10,11,...]
```
[Answer]
# [Haskell](https://www.haskell.org/), 43 bytes
```
0:1:3:2:5!3
a!n=a:[a-n+2..a-1]++(a+n)!(n+1)
```
[Try it online!](https://tio.run/##BcFBCoMwEAXQfU8x2SUMkURxM5CTtF18xKoYh9B4/k7f29HPtVbr5WVJskwyyuymB5wWyBNReRwGxPxm9mANzivnYBcOpULte@hN/sa5Uk6JerDf8qnYusWltT8 "Haskell – Try It Online")
Defines an infinite list:
```
  0:1:3:2:(5!3)
≡ 0:1:3:2:5:4:(8!4)
≡ 0:1:3:2:5:4:8:6:7:(12!5)
≡ 0:1:3:2:5:4:8:6:7:12:9:10:11:(17!6)
≡ 0:1:3:2:5:4:8:6:7:12:9:10:11:17:13:14:15:16:(23!7) …
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
+‘ɼṪRṙ-œ|@
0Ç¡ḣ
```
This is a full program that, given **n**, prints the first **n** items of the sequence.
[Try it online!](https://tio.run/##AScA2P9qZWxsef//K@KAmMm84bmqUuG5mS3Fk3xACjDDh8Kh4bij////MTk "Jelly – Try It Online")
### How it works
```
0Ç¡ḣ        Main link. Argument: n
0           Set the return value to 0.
 Ç¡         Call the helper link n times, first with argument 0, then n-1 times
            with the previous return value as argument.
   ḣ        Head; extract the first n items of the last return value.
+‘ɼṪRṙ-œ|@  Helper link. Argument: A (array)
 ‘ɼ         Increment the value in the register (initially 0) and yield it.
+           Add that value to all items in the sequence.
   Ṫ        Tail; extract the last item.
    R       Range; map k to [1, .., k].
     ṙ-     Rotate -1 units to the left, yielding [k, 1, ..., k-1].
       œ|@  Perform multiset union of A and the previous return value.
```
[Answer]
## C (gcc), ~~73~~ ~~67~~ 64 bytes
```
t,d;f(x){for(t=4,d=2;d<x;t+=d++)x-t||(d+=x+=d);t=x<4?x^x/2:x-1;}
```
[Try it online!](https://tio.run/##DYzLCsIwEEX3/YqhImRI66N05ST6IyJIxmigplIjDLT99pizORwuXNc@ncubEN3w4weYb@Iw7l7nnBomrwRnP04q2b5h2xEboaQta43SpmVRrK2URkpWTH@Rm@y7k7RHWvP7HqJCmCsolBNQISYIYOFARQa6Yq0Dwmcqi1f1lq@xbsCrgEjVmv8)
Defines a function `f` that takes 0-indexed `n` and produces the `n`th number in the sequence.
We can analyze the sequence as follows:
```
f(n)  = n   where n = 0, 1
f(2)  = 3   // 2 and 3 are swapped
f(3)  = 2
f(4)  = 5   // (+2,+3)
f(6)  = 8   // (+3,+4)
f(9)  = 12  // (+4,+5)
f(13) = 17  // (...)
...
f(n)  = n-1 // for all cases not yet covered
```
First we handle the middle section:
```
for(t=4,d=2;d<x;t+=d++)x-t||(d+=x+=d);
```
Note that the arguments on the left (4, 6, 9, 13, ...) follow a pattern: first add two, then add three, then add four, and so on. We start at `t=4` and add `d` (which starts at 2) each iteration of the loop, incrementing `d` in the process.
The body of the loop is more interesting. Remember that we want to map 4 to 5, 6 to 8, 9 to 12, etc.; that's just adding `d-1` if `x` is `t`. However, this logic comes before the last case, `f(n) = n - 1`, so we know we're going to subtract 1 at the end. Therefore, we can simply add `d` if `x == t` (`x-t||(x+=d)`). However, we will also need to break out of the loop immediately after this -- so we add *that* to `d` to get the absurd-looking `d+=x+=d`, which will always make the `d<x` condition fail.
This covers everything except for the first four values. Looking at them in binary, we get:
```
00 -> 00
01 -> 01
10 -> 11
11 -> 10
```
So, we want to flip the last bit if `2 <= x < 4`. This is accomplished with `x^x/2`. `x/2` gives the second least significant bit, so XORing this with the original number flips the last bit if the number is 2 or 3.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~13~~ 10 [bytes](https://github.com/DennisMitchell/jelly)
-3 Thanks to Dennis (use 0-indexing to save 2 from cumulative sum setup and a final decrement)
```
Ḷ»2Äi+_>2$
```
A monadic link accepting an integer, **0**-indexed **n**, which returns an integer, **a(n)**
**[Try it online!](https://tio.run/##y0rNyan8///hjm2HdhsdbsnUjrczUvn//78lAA "Jelly – Try It Online")** Or see a [test-suite](https://tio.run/##y0rNyan8///hjm2HdhsdbsnUjrczUgFxD7c/alrz/7@ZKQA "Jelly – Try It Online")
[Answer]
## [Perl 5](https://www.perl.org/) with `-pl`, 70 bytes
```
$"="|";push@f,$;=$f[-1]+$-++,grep!/^(@f|$;)$/,0..$;for 0..$_;$_=$f[$_]
```
[Try it online!](https://tio.run/##FcpLDoIwFEbh@b8Kbe4A0ha4vE3ThH0YZETVhNgGdMbarTI7@XLCvC5NJG0HZ5PURBJW7MKEz/YYnCJjyV01j5K0lOq@zuGc35LB7WRSylWRZWScX09HTIamY6dpjLEAo0SFGg1adOhxAf@RwSW4AtfgBtyCO3D/9eH99K8t6rD8AA "Perl 5 – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 22 bytes
```
1y:"t0)@+h5M:yX-h]qw:)
```
Outputs the first `n` terms of the sequence.
[Try it online!](https://tio.run/##y00syfn/37DSSqnEQNNBO8PU16oyQjcjtrDcShMobgkA "MATL – Try It Online")
### Explanation
```
1         % Push 1
y         % Implicit input: n. Duplicate from below
":        % For each k in [1 2 ... n]
  t0)     %   Duplicate sequence so far. Get last entry, say m
  @+      %   Add k: gives m+k
  h       %   Concatenate horizontally
  5M      %   Push m+k again
  :       %   Range [1 2 ... m+k]
  y       %   Duplicate from below
  X-      %   Set difference
  h       %   Concatenate horizontally
]         % End
q         % Subtract 1, element-wise
w         % Swap. Brings original copy of n to the top
:)        % Keep the first n entries. Implicit display
```
[Answer]
# [Haskell](https://www.haskell.org/), 51 bytes
```
0:1:do(a,b)<-zip=<<(1:)$scanl(+)3[2..];b:[a+1..b-1]
```
[Try it online!](https://tio.run/##BcFBEsIgDADAr@TQA0yFIXpDeEnbQ8BWmSIypqc@3rj7It7XWoXjLM6jf3wUXZIO5iw9hqDQ64EztapGfZuu1i735Cca0dpkcJE3lQYR@re0A9RB@wroHLCWX94qPVlM7v0P "Haskell – Try It Online")
Quite a bit longer than [Lynn's Haskell answer](https://codegolf.stackexchange.com/a/167325/56433), but the different approach might be interesting non the less.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 73 bytes
```
f=->x,l,n{!l[x]&&(i=l[-1];f[x,l+[i+n]+([*(i+1...i+n)]-l),n+1])||l[0...x]}
```
[Try it online!](https://tio.run/##DchBCoAgEADAr9QltF1Fo1vYR5a9dBCERSIIjOzt5nHmuo@ntRjMXlAwv6NQ4WlSKQgZz1uk/kAJMoOiWSXw1tpOzUY0ZvCsaxVyfQt/7RwiLSuSY/Tcfg "Ruby – Try It Online")
Recursive function that returns the first x numbers of the list.
[Answer]
# QBasic, 58 bytes
```
DO
b=r+j
?b
r=b
FOR x=a+1TO b-1
?x
r=x
NEXT
a=b
j=j+1
LOOP
```
Outputs indefinitely. You may want to add a `SLEEP 1` inside the loop or make it `LOOP WHILE b<100` or something like that in order to see the results.
This basically just implements the spec. Observe that the numbers we go back for will always be the numbers between the most recently jumped-to number and the jumped-to number prior to that. So we store these bounds as `a` and `b` and use a `FOR` loop to print all the numbers between them.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes
```
0)sƒ¤N+LÁ«}Ùs£
```
[Try it online!](https://tio.run/##ASAA3/8wNWFiMWX//zApc8aSwqROK0zDgcKrfcOZc8Kj//8yMA "05AB1E – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 70 bytes
```
function(e){for(i in 1:e)F=c(setdiff((F+i):1-1,F),F[1]+i,F);rev(F)[e]}
```
[Try it online!](https://tio.run/##TcsxDsIwDADAPa/wZls1Q5BYirLmE6VDFWLkJUVJgaHq2wMj2y1Xu4aur5I2Wwtl3nWtZGAF/Jg5hkQtb3dTJYqD8ehPXiJLnPw82E/Xmt8Uecrz0f/q@cK7A0jLRqiEYoIMAVCUjAVvBaXlZ0Bkd7jPUouVRyPuXw "R – Try It Online")
* 1-indexed
* -4 bytes using `F` constant thanks to @JAD suggestion
* -5 bytes reversing the list thanks to @Giuseppe suggestion
* -2 bytes removing useless braces in for loop thanks to @JAD suggestion
* -2 bytes using `setdiff` instead of `x[x %in% y]`
---
[Previous version (79 bytes)](https://tio.run/##TcyxCsMgEIDhPU9hh3B39AKxY1JXXyLNIKJwUIykdgo@u3Xs9v3Lf7ZoWvwmX@RIGOiKx4miJCm99MqmOHmjZU2rNb4j34XRPad5wc5JE203N0oa7U51tVvYa/t7PGa6BqW8KwgRgYWBlFHAEYUYXgn4E7IBoKG2Hw)
[Answer]
# [Python 2](https://docs.python.org/2/), 123 bytes
```
def f(z):[s.extend([s[-1]+n]+[x for x in range(s[-1]+1,s[-1]+n)if not x in s]) for n in range(1,z)if len(s)<z];return s
```
[Try it online!](https://tio.run/##Rc3LCsIwEIXhV5llQqs4Lr08SchC6EQDMikzEdK8fIxtwbP9Pzjzkl@Jz03hDu7k20QBgqn24vRIJRNPxqk7oB/YD65ASAIFIoM8@ElmSzjuxMYAnPIm1NuV85/jWH/kTWzU3qq/CuWPdAp9bZbIub8j2vYF "Python 2 – Try It Online")
Given input x, output the first x terms of the sequence,
I'm learning Python and this challenges make things more interesting.
Edit: shave some whitespace
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
RÄṬŻk²Ḋ$ṙ€-Ø.;Fḣ
```
[Try it online!](https://tio.run/##ASkA1v9qZWxsef//UsOE4bmsxbtrwrLhuIok4bmZ4oKsLcOYLjtG4bij////Ng "Jelly – Try It Online")
One byte longer than the existing Jelly answer but this could possibly be golfed a little. `RÄṬŻk²Ḋ$` could maybe be shorter.
[**18 bytes**](https://tio.run/##ATMAzP9qZWxsef//UsOE4bmsxbtrwrLhuIok4oCY4bmZ4oKsMUbFu8W74buk4oCZ4bij////MTA "Jelly – Try It Online")
```
RÄṬŻk²Ḋ$‘ṙ€1FŻŻỤ’ḣ
```
Longer but different.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 63 bytes
```
->x,n=0{n+=1while 0>d=n*n+n<=>2*x-6;[0,1,3,2][x]||[x+n,x-1][d]}
```
[Try it online!](https://tio.run/##BcFLCsIwEADQq4S60ebDJIIbnVwkzEJtSwMylKI4kuTs8b398/j1BbuNYhihsEb/XfNrVhAn5JE13zCGUezlmsB4czaBklCtSTQbsZ7SRK0fwbkAJzffn6sqNVe17ZnfajiUJWVqamj9Dw "Ruby – Try It Online")
0-indexed. Can probably be golfed down.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 52 bytes
```
(0,{((^max @_)∖@_).min.?key//(1+@_[*-1]+$++)}...*)
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoFKcWmj7X8NAp1pDIy43sULBIV7zUcc0IKmXm5mnZ5@dWqmvr2Go7RAfraVrGKutoq2tWaunp6el@d@aqzgRYkB0nJFB7H8A "Perl 6 – Try It Online")
This is a generator expression using the `...` operator. It looks for gaps in the prior sequence `@_` via `((^max @_)∖@_).min.?key`:
```
      @_  # prior sequence values         [0,1,3]
  max @_  # largest prior sequence value       3
 ^        # the Range 0..max @_            0,1,2
(       )∖@_  # set subtract prior seq     -0,1  -> (2=>True)
            .min  # smallest unseen value  2=>True
                .?key  # set yields pairs  2
```
The `?` is necessary for the initial value which doesn't have a `.key`. If no gaps are found, then it adds n (here in the `$` variable) to the last value in the list, plus one for off by 0 errors.
[Answer]
# [Python 3](https://docs.python.org/3/), 104 bytes
```
def f(x):
 n=a=0
 l=list(range(x*x))
 while n<x:print(l[a+n],*l[a+2-(n<3):a+n],end=' ');a=a+n-(a>0);n+=1
```
[Try it online!](https://tio.run/##HchBCoMwEEDRfU4xO2e0gqm76PQixcWASQ2EqdhA09OntavP@/snb08da119gICFnAFl4cFA4hRfGQ/Rh8fSFiID7y0mDzoXtx9RM6a7dLpc2rPXHnUeyf2P15UbaGgS/rlHuQ00ace2BrSW6hc "Python 3 – Try It Online")
Given input x, output the first x "sequences"
]


[Question]
      [
# Background
This is a standard textbook example to demonstrate for loops.
This is one of the first programs I learnt when I started learning programming ~10 years ago.
# Task
You are to print this exact text:
```
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
```
# Specs
* You may have extra trailing newlines.
* You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest answer in bytes wins.

[Answer]
# [Python 2](https://docs.python.org/2/), 21 bytes
```
exec'print"*"*10;'*10
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P7UiNVm9oCgzr0RJS0nL0MBaHUj8/w8A "Python 2 – Try It Online")
[Answer]
# [Glee](https://withglee.com/Frames/GFMain.htm), 17 bytes
```
('*'%%10\)%%10,,\
```
Explanation:
```
('*'                          create '*'
    %%10                      reshape to length 10
        \)                    monadic segment with CRLF
          %%10                reshape to sequence length 10
              ,,\             expose with LF separators
```
[Answer]
# Powershell, 12 bytes
```
@('*'*10)*10
```
## Explanation
```
  '*'*10      create a string with 10 '*'
@('*'*10)     create an array with one element of string with 10 '*'
@('*'*10)*10  repeat elements of this array 10 times
```
[Answer]
# [Ahead](https://github.com/ajc2/ahead), ~~21~~ 18 bytes
```
~oK:k9*'N@k=11:+1~
```
[Try it online!](https://tio.run/##S8xITUz5/78u39sq21JL3c8h29bQ0ErbsO7/fwA "Ahead – Try It Online")
[Answer]
# [ESOPUNK](http://esolangs.org/wiki/ESOPUNK), ~~167~~ ~~78~~ 77 bytes
```
MARK L
@REP 10
COPY 42 #STDO
@END
COPY 10 #STDO
TEST X = 9
ADDI X 1 X
FJMP L
```
I haven't been bothered to implement the preprocessor, but this *should* work when I do.
[Answer]
# [Julia 1.0](http://julialang.org/), 23 bytes
```
print(("*"^10*"\n")^10)
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/v6AoM69EQ0NJSynO0EBLKSZPSRPI0Pz/HwA "Julia 1.0 – Try It Online")
[Answer]
# [A0A0](https://esolangs.org/wiki/A0A0), 145 bytes
```
A0A0
A0C3G1G1G1G1G1G1G1G1G1G1G1A0
A0P42P42P42P42P42P42P42P42P42P42G3P10A0
A0A1G-3G-3G-3G-3G-3G-3G-3G-3G-3G-3G-3A0
G-3
G-2G-2G-2G-2G-2G-2G-2G-2G-2
```
The top five lines are for the loop construction. A0A0 deletes instructions whenever it runs them, so those lines ensure that the loop keeps running. On line 3 are ten P42 instructions which print `*` (42 is the ascii code for an asterisk). The P10 instruction prints a new line.
The bottom line acts as a counter. For every execution of the loop it jumps to there and then jumps back to the loop. This consumes an instruction on that line. There are exactly nine instructions, so when it tries to go there when it has already printed ten lines the program will halt execution (since an empty line swill stop execution in A0A0).
[Answer]
# [Pascal (FPC)](https://www.freepascal.org/), 57 bytes
```
var i:word;begin for i:=0to 9do writeln('**********')end.
```
[Try it online!](https://tio.run/##K0gsTk7M0U0rSP7/vyyxSCHTqjy/KMU6KTU9M08hLR8kYGtQkq9gmZKvUF6UWZKak6ehrgUH6pqpeSl6//8DAA "Pascal (FPC) – Try It Online")
This is probably the best one as I don't see how this can be improved in 9 characters or less which could be gained by removing `*`s.
[Answer]
# [Assembly (NASM, 32-bit, Linux)](https://www.nasm.us/), 122 bytes
```
mov ecx,10
n:push 0xa202a2a
push '****'
push '****'
loop n
mov edx,120
mov ecx,esp
mov ebx,1
mov eax,4
int 128
add esp,120
```
[Try it Online!](https://jdoodle.com/a/2s1A)
[Answer]
### x86\_16 machine code - 37 bytes
```
B4 0E            MOV AH, 0EH
B9 000A          MOV CX, 10
8B D1            MOV DX, CX
8B D9            MOV BX, CX
             .LOOP:
B0 2A            MOV AL, "*"
CD 10            INT 10H
E3 02            JCXZ .NEWLINE
E2 F8            LOOP .LOOP
             .NEWLINE:
B0 0A            MOV AL, 10
CD 10            INT 10H
B0 0D            MOV AL, 13
CD 10            INT 10H
8B CB            MOV CX, BX
4A               DEC DX
74 02            JZ .EXIT
75 E9            JNZ .LOOP
             .EXIT:
B8 004C          MOV AX, 4C00H
CD 21            INT 21H
```
Running using DOSBox :
[![10-GRID Screenshoot](https://i.stack.imgur.com/MfdVy.png)](https://i.stack.imgur.com/MfdVy.png)
[Answer]
# Java, 46 bytes
```
$->System.out.print("**********\n".repeat(10))
```
[Try it online!](https://tio.run/##PYw/C8IwFMT3fopHcWgKDTpXXZydCi7qENNYUvOP5KUg0s8eI5X@luPd3buRTawZ@1eS2lmPMOabRpSKPqPhKK2hdVu4@FCSA1csBDgzaeBTQObvB2SYZbKyB53TqkMvzXC9A/NDIEv3x8maELXw@0uuHoEf0qY5du@AQlMbkbr8hlVZr9xMSb1wgmG12xKS2nWKU8a5cFiZqBRZ/LmY0xc)
[Answer]
### Python 3 (23 bytes)
```
print(('*'*10+'\n')*10)
```
[Answer]
# [Swift](https://developer.apple.com/swift/), 54 bytes
```
for _ in 0...9 {print(String(repeating:"*",count:10))}
```
[Try it online!](https://tio.run/##Ky7PTCsx@f8/Lb9IIV4hM0/BQE9Pz1KhuqAoM69EI7gESKVrFKUWpCaWAFlWSlpKOsn5pXklVoYGmpq1//8DAA "Swift – Try It Online")
[Answer]
## X86-64/Linux Machine Code, 32 bytes
[Try it online!](https://tio.run/##bVNfa9swEH@2P8VBFtJmSeqMMcYgD6HLIFDWh6ashUGQ7LOtTpaMJMfJPvy8k@UuC5tffOc73e/PycxarLg8zYs07bqbKdzqqkLlQDcONk/b3f72brP@evcMToNlB4T3wE8O7QKmN/Eow1wovGiM42hRSM2ZjPbWMeMod3h0ccg@xRGhbFWqK6EKMFgI69BYYAbhJxq9AD@573q0CHQo/QG5NhRpwwoM9ahubBmNja0p1LWPRBxLresAMJlOQCivoiYhvMlzNMPJSh949CY5vmMzuPLnrgPaF2GsA6MblUGLUHqxD88Pe4Msg7cgURWuhATaUqQlCAtI3iknmJSnOAIABkrXA4g92ZQK/eC1tU0vVmnY3gMao80M/Nir5BpaISUlrjEKkr/E8x5DKBEQIJmB1eBK@thqNXHgxXqNQwvk1OZK4l@UA4kMUx6NeRlHL0Xk2@OzehJPFQ9EMaxWMPmuJouzQVT8Y0/YWEAJ/gQanjnHoJvYsYpiWiTXB/yPDd7L1giHF3tYEg82NOw@3z/uzlUZjZEdqY6Z6BuWc3/1gDmCdKL6d1Amg3frnK4ULBMQ/n0m2@/UikJhBkTS5FK3wxCWZb0vqfeF@LwoGywbiZxu@eUV9xibo3AXBD4kg5RX0SNUmci77leaS1bYbq60dZkU3Ec0kzXSUTYU6N/IhUTKKHYipXc3/yZn8x23dpUcPybh@Q0 "Assembly (gcc, x64, Linux) – Try It Online")
**Usage:**
```
$> gcc -s -static -nostartfiles -nodefaultlibs -nostdlib -Wl,--build-id=none print.S -o print
$> ./print
```
**Notes:**
* Size is measured in machine code (i.e 32 bytes of PROGBITS; .text, .data, etc...)
* -4 more bytes without `EXIT_CLEANLY` (it will segfault to exit).
```
/* Comment out EXIT_CLEANLY to save 4 bytes. */
#define EXIT_CLEANLY
    .global _start
    .text
_start:
    /* Incoming registers are zero.  */
    /* Use stack for storage.  */
    push    %rsp
    pop %rsi
loop:
    /* '*' in output buffer.  */
    movb    $0x2a, (%rsi)
    /* First round we have SYS_read + length 0 which is essentially
       a nop.  */
    syscall
    /* Assuming no IO error, read(0) will return 0.  */
    /* bh is initially 0, so this won't loop in initial fallthrough.  */
    decb    %bh
    jg  loop
    movb    $0xa, %bh   /* 0xa == '\n'. */
    movb    %bh, (%rsi)
    /* Initial round this will be a nop, same as above.  */
    syscall
    /* SYS_write.  */
    movb    $1, %al
    /* STDOUT.  */
    movl    %eax, %edi
    /* 1-byte at a time.  */
    movb    $1, %dl
    /* After 10 iter this will have signed overflow.  */
    addb    $0xc, %bl
    jns loop
#ifdef EXIT_CLEANLY
    /* Exit.  */
    movb    $60, %al
    syscall
#endif
```
```
[Answer]
# [morsecco](https://codegolf.meta.stackexchange.com/a/26119/72726): 109 bytes
The shortest way seems to be to define a new command repeating a given string a given times:
```
.  . .- .- --.. .. - -. - . -. -.-. . ..  . -. .-- . -.-.-. -.- - . -.-. -. . -.-. -.- - -.-. . . -.-. -. ---
```
The command itself is only 37 bytes:
* `. .- .-` to decrement the number (`E`nter minus 1 and `A`dd)
* `--.. ..` to `Z`eroskip to the `..`, leaving the input string
* `- -. - .` we need some stack juggling to duplicate the next of stack (over and swap)
* `-.` is the recursive call with the decremented number
* `-.-. .` `C`oncatenates the returned string from the command to itself
* `..` is currently not used, so it can currently be used as a skip target. This may fail in future versions of morsecco
Unfortunately, the surrounding code is twice as long:
* `. -. .--` `W`rites the code to address `-.`
* `. -.-.-. -.- -` `E`nter 42 and `K`onvert to `T`ext
* `. -.-. -.` `E`nter 10 and call the new command
* `. -.-. -.- - -.-. .` add the newline to the string; expensive, but necessary
* `. -.-. -. ---` call the new command again with 10 and `O`utput
Fun fact: this is the length of the challenge output (100 stars plus 9 newlines). Always keep in mind that morsecco wastes a factor 5 of bytes by restricting itself to only three symbols. With 22 real information bytes, it could compete.
[Answer]
# HTML, 136 bytes
```
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
```
]


[Question]
      [
It seems that many people would like to have this, so it's now a sequel to [this challenge](https://codegolf.stackexchange.com/questions/167106/recover-the-prime-from-the-prime-power)!
**Definition**: a *prime power* is a natural number that can be expressed in the form pn where p is a prime and n is a natural number.
**Task**: Given a prime power pn > 1, return the power n.
**Testcases**:
```
input output
9     2
16    4
343   3
2687  1
59049 10
```
**Scoring**: This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest answer in bytes wins.

[Answer]
# [Python 2](https://docs.python.org/2/), 37 bytes
```
f=lambda n,i=2:i/n or(n%i<1)+f(n,i+1)
```
[Try it online!](https://tio.run/##DYpBCsIwFAX3nuJthIQGa1KpWuxJxEXVFj80P@EnXfT0MQOzGSbu@RfYFfIxSEba06F6SnOW@bNJosArecrKniu6LOM6@fd3Ahsa3UAtI4jiIz2sbhZVa2PrFQQMYjydwd3A9gbdpTNw/e36GhCFOKPuuvwB "Python 2 – Try It Online")
Counts factors. Apparently I wrote the [same golf](https://codegolf.stackexchange.com/a/64948/20260) in 2015.
Narrowly beats out the non-recursive
**[Python 2](https://docs.python.org/2/), 38 bytes**
```
lambda n:sum(n%i<1for i in range(1,n))
```
[Try it online!](https://tio.run/##FchBCoMwFAXAq7yNkMDfJEpaRU/Suoi0qQF9SrQLTx/JLGe/znmjzWF458Wv08eD3fFfFavYm7AlREQief6@ygi1ziVZ8mUFrcA4Qd3UAuuej7HDniJPBEWdbw "Python 2 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 2 bytes
```
Òg
```
[Try it online!](https://tio.run/##MzBNTDJM/f//8KT0//9NLQ1MLAE "05AB1E – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 49 bytes
```
f=lambda n,x=2:n%x and f(n,x+1)or n/x<2or-~f(n/x)
```
[Try it online!](https://tio.run/##DYtBDoIwFAX3nOJtTNpYBQqiEDmJcVEFYhP4Je03KRuvjn3JLGaSt278cVTtdlmdZ4QtZIlzGNmP768P1tFsF8uiLNLkPvWzWV6DAanY644OEYYGTCL5sZTOg/J4186ffqnlMT1SY1jCo1UoG4WqrhR0c7sqXNqibp9dBqzeEotJsJT7Hw "Python 3 – Try It Online")
Outputs `True` instead of 1 ([as allowed by OP](https://codegolf.stackexchange.com/questions/167199/recover-the-power-from-the-prime-power#comment404175_167199)). Recursive function that repeatedly finds the lowest factor and then calls the function again with the next lowest power until it reaches 1. This is an extension of [my answer](https://codegolf.stackexchange.com/a/167125/76162) to the previous question.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), \$\require{cancel}\xcancel 4 3\$ bytes
```
|f%
```
[Run and debug it](https://staxlang.xyz/#c=%7Cf%25&i=9%0A16%0A343%0A2687%0A59049&a=1&m=2)
Length of prime factorization.
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + GNU utilities, 22
* 2 bytes saved thanks to @H.PWiz and @Cowsquack
```
factor|tr -cd \ |wc -c
```
[Try it online!](https://tio.run/##RYpBCsIwEEX3c4pP0WVBba2GgifpJs5MSUEaSQa6yd1jEcS/erz3nz6HuoXlpUjqBabZ2GcdIZGw752W1WY0R0H7QIPD7/GtyiH@FQqmOnu2mIoltCyYUDbeqUpctTo6D9T1HV2G@42u7tQ7@gA "Bash – Try It Online")
[Answer]
# [R](http://cran.r-project.org) 22 bytes
Power `n` is the number of multiples of `p` in `p^n` when `p` is prime:
```
sum(!(b<-scan())%%2:b)
```
[Try it online!](https://tio.run/##K/r/v7g0V0NRI8lGtzg5MU9DU1NV1cgqSfO/5X8A "R – Try It Online")
[Answer]
## [Nibbles](http://golfscript.com/nibbles) 5 bytes
```
,|`,$~^%@
```
This is 9 nibbles each of which is encoded in a half byte in the binary form. I think this is the shortest solution that doesn't use built in factoring.
Translation:
```
,      length
 |     filter
  `,$  0..input
  ~    not \x->
   ^   pow (so that 0 which would have been 0 from the mod isn't)
    %  mod
     @ input
     implicit $ (x)
    implicit $ (x)
```
It works by just counting the number of numbers the input divides evenly
You could run it passing in a list of numbers to process in stdin or as a command line arg. Nibbles isn't on TIO.run yet...
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), ~~50~~ 41 bytes
```
1si[dli1+dsi%0<X]dsXx[dli/dli<Y]sYdli<Yzp
```
[Try it online!](https://tio.run/##S0n@b2j@37A4MzolJ9NQO6U4U9XAJiI2pTiiAiSiD8Q2kbHFkWC6quD/fwA "dc – Try It Online")
Takes input from the top of the stack (in TIO, put the input in the header to load it onto the stack before execution). Outputs to stdout.
# Explanation
**Registers used:**
`i`: the current trial divisor, while `X` is running. Later, the divisor we've found.
`X`: the macro `dli1+dsi%0<X`, which has the effect "increment `i`, then check the modulus with the value on the stack (which will be the original input). If it's not zero, repeat".
`Y`: the macro `dli/dli<Y`, which has the effect "Add to the stack a copy of the current top of the stack, divided by `i`. Repeat until `i` is reached."
Full program:
```
1si                 Initialize i
[dli1+dsi%0<X]dsXx  Define and run X
[dli/dli<Y]sY       Define Y
dli<Y               Run Y, but only if needed (if the input wasn't just i)
z                   The stack is i^n, i^(n-1), ... ,i, so print the stack depth
```
[Answer]
# Pyth, 2
Count prime factors:
```
lP
```
[Online test](https://pyth.herokuapp.com/?code=lP&input=59049&test_suite=1&test_suite_input=9%0A16%0A343%0A2687%0A59049&debug=0).
[Answer]
# [face](https://github.com/KeyboardFire/face), 86 bytes
```
(%d@)\$*,c'$,io>Av"[""mN*c?*m1*mp*m%*s1"$pN1p:~+p1p%%Np?%~:=/NNp+?1?-%N1?%=p%'$i?w1'%>
```
Hooray, longer than Java!
[Try it online!](https://tio.run/##BcFBCoNADAXQuwzzmTZaakAXCpr2ArlAu5GpgovBgNDuvHr63jrnxf2Cz@P6jlTnFOttn57f8AqhKGWhwlSMCujgEE3ZhrMyNkBNcA7jXdUqYblBWTAaUtzkxwmTu3d90/Z/)
I am particularly fond of the trick of using the return value of `sscanf`.
Normally the return value would be discarded,
but here it will always be 1,
because we're always reading a single number as input.
We can take advantage of this
by assigning its return value to the variable `1`,
saving the 2 bytes that would otherwise be required
to assign `1` to 1 explicitly.
```
(%d@)
\$*,c'$,io>  ( setup - assign $ to "%d", * to a number, o to stdout )
Av"[""mN*    ( set " to input and allocate space for N for int conversion )
c?*          ( calloc ?, starting it at zero - this will be the output )
m1*          ( allocate variable "1", which gets the value 1 eventually )
mp*m%*       ( p is the prime, % will be used to store N mod p )
s1"$pN       ( scan " into N with $ as format; also assigns 1 to 1 )
1p:~         ( begin loop, starting p at 1 )
  +p1p       ( increment p )
  %%Np       ( set % to N mod p )
?%~          ( repeat if the result is nonzero, so that we reach the factor )
:=           ( another loop to repeatedly divide N by p )
  /NNp       ( divide N by p in-place )
  +?1?       ( increment the counter )
  -%N1       ( reuse % as a temp variable to store N-1 )
?%=          ( repeat while N-1 is not 0 -- i.e. break when N = 1 )
p%'$i?       ( sprintf ? into ', reusing the input format string )
w1'%>        ( write to stdout )
```
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache) and [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/) polyglot, 10 bytes
```
PrimeOmega
```
[Try Attache online!](https://tio.run/##SywpSUzOSP2fpmBlq/A/oCgzN9U/NzU98b9fampKcbRKQUFyeiwXUDyvJCS1uMQ5sTi1ODpNRyHaUkfB0ExHwdjEWEfByMzCXEfB1NLAxDI29j8A "Attache – Try It Online") [Try Mathematica online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/A/oCgzN9U/NzU9EcTMK4n2TSyITtNRqLbUUTA001EwNjHWUTAyszDXUTC1NDCxrI2N/Q8A "Wolfram Language (Mathematica) – Try It Online")
Simply a builtin for computing the number of prime factors **N** has.
## Explanation
Since **N** = **p***k*, Ω(**N**) = Ω(**p***k*) = *k*, the desired result.
[Answer]
# Whitespace, 141 bytes
```
[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_number][T    T   T   _Retrieve][S S S T  N
_Push_1][N
S S N
_Create_Label_LOOP_1][S S S T   N
_Push_1][T  S S S _Add][S N
S _Duplicate][S T   S S T   S N
_Copy_2nd_input][S N
T   _Swap_top_two][T    S T T   _Modulo][N
T   S S N
_If_0_Jump_to_Label_BREAK_1][N
S N
N
_Jump_to_Label_LOOP_1][N
S S S N
_Create_Label_BREAK_1][S S S N
_Push_0][S T    S S T   S N
_Copy_2nd_input][N
S S T   N
_Create_Label_LOOP_2][S N
S _Duplicate_input][S S S T N
_Push_1][T  S S T   _Subtract][N
T   S S S N
_If_0_Jump_to_Label_BREAK_2][S N
T   _Swap_top_two][S S S T  N
_Push_1][T  S S S _Add][S N
T   _Swap_top_two][S T  S S T   S N
Copy_2nd_factor][T  S T S _Integer_divide][N
S N
T   N
_Jump_to_Label_LOOP_2][N
S S S S N
_Create_Label_BREAK_2][S N
N
_Discard_top][T N
S T _Print_as_number]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.
[Try it online](https://tio.run/##TYxLCoAwEEPXySnmDvVCIgXdCQoef5p0urAfyGRe8p3X2597P3pmRFAXhI8mkLYsPFrCT5T2mK4QGov6tTfI6VS08o79yrBgrMbZYiUZyGxbGw) (with raw spaces, tabs and new-lines only).
**Explanation in pseudo-code:**
```
Integer n = STDIN as input
Integer f = 1
Start LOOP_1:
  f = f + 1
  if(n modulo-f == 0)
    Call function BREAK_1
  Go to next iteration of LOOP_1
function BREAK_1:
  Integer r = 0
  Start LOOP_2:
    if(n == 1)
      Call function BREAK_2
    r = r + 1
    n = n integer-divided by f
    Go to next iteration of LOOP_2
function BREAK_2:
  Print r as number to STDOUT
  Program stops with an error: Exit not defined
```
**Example run: [`input = 9`](https://tio.run/##TYxLCoBADEPXySl6DY8jMjDuBAWPX5N2Fs4H0vQl7zyfcV/7MTIjgrogfDSBtGXh0RJ@orRHuUJoLPr33iDL6WjnHfuVYcFYjdViJRnI3D4)**
```
Command    Explanation                    Stack           Heap    STDIN   STDOUT   STDERR
SSSN       Push 0                         [0]
SNS        Duplicate top (0)              [0,0]
TNTT       Read STDIN as number           [0]             {0:9}   9
TTT        Retrieve                       [9]             {0:9}
SSSTN      Push 1                         [9,1]           {0:9}
NSSN       Create Label_LOOP_1            [9,1]           {0:9}
 SSSTN     Push 1                         [9,1,1]         {0:9}
 TSSS      Add top two (1+1)              [9,2]           {0:9}
 SNS       Duplicate top (2)              [9,2,2]         {0:9}
 STSSTSN   Copy 2nd from top              [9,2,2,9]       {0:9}
 SNT       Swap top two                   [9,2,9,2]       {0:9}
 TSTT      Modulo top two (9%2)           [9,2,1]         {0:9}
 NTSSN     If 0: Jump to Label_BREAK_1    [9,2]           {0:9}
 NSNN      Jump to Label_LOOP_1           [9,2]           {0:9}
 SSSTN     Push 1                         [9,2,1]         {0:9}
 TSSS      Add top two (2+1)              [9,3]           {0:9}
 SNS       Duplicate top (3)              [9,3,3]         {0:9}
 STSSTSN   Copy 2nd                       [9,3,3,9]       {0:9}
 SNT       Swap top two                   [9,3,9,3]       {0:9}
 TSTT      Modulo top two (9%3)           [9,3,0]         {0:9}
 NTSSN     If 0: Jump to Label_BREAK_1    [9,3]           {0:9}
NSSSN      Create Label_BREAK_1           [9,3]           {0:9}
SSSN       Push 0                         [9,3,0]         {0:9}
STSSTSN    Copy 2nd from top              [9,3,0,9]       {0:9}
NSSTN      Create Label_LOOP_2            [9,3,0,9]       {0:9}
 SNS       Duplicate top (9)              [9,3,0,9,9]     {0:9}
 SSSTN     Push 1                         [9,3,0,9,9,1]   {0:9}
 TSST      Subtract top two (9-1)         [9,3,0,9,8]     {0:9}
 NTSSSN    If 0: Jump to Label_BREAK_2    [9,3,0,9]       {0:9}
 SNT       Swap top two                   [9,3,9,0]       {0:9}
 SSSTN     Push 1                         [9,3,9,0,1]     {0:9}
 TSSS      Add top two (0+1)              [9,3,9,1]       {0:9}
 SNT       Swap top two                   [9,3,1,9]       {0:9}
 STSSTSN   Copy 2nd from top              [9,3,1,9,3]     {0:9}
 TSTS      Integer-divide top two (9/3)   [9,3,1,3]       {0:9}
 NSNTN     Jump to Label_LOOP_2           [9,3,1,3]       {0:9}
 SNS       Duplicate top (3)              [9,3,1,3,3]     {0:9}
 SSSTN     Push 1                         [9,3,1,3,3,1]   {0:9}
 TSST      Subtract top two (3-1)         [9,3,1,3,2]     {0:9}
 NTSSSN    If 0: Jump to Label_BREAK_2    [9,3,1,3]       {0:9}
 SNT       Swap top two                   [9,3,3,1]       {0:9}
 SSSTN     Push 1                         [9,3,3,1,1]     {0:9}
 TSSS      Add top two (1+1)              [9,3,3,2]       {0:9}
 SNT       Swap top two                   [9,3,2,3]       {0:9}
 STSSTSN   Copy 2nd from top              [9,3,2,3,3]     {0:9}
 TSTS      Integer-divide top two (3/3)   [9,3,2,1]       {0:9}
 NSNTN     Jump to Label_LOOP_2           [9,3,2,1]       {0:9}
 SNS       Duplicate top (1)              [9,3,2,1,1]     {0:9}
 SSSTN     Push 1                         [9,3,2,1,1,1]   {0:9}
 TSST      Subtract top two (1-1)         [9,3,2,1,0]     {0:9}
 NTSSSN    If 0: Jump to Label_BREAK_2    [9,3,2,1]       {0:9}
NSSSSN     Create Label_BREAK_2           [9,3,2,1]       {0:9}
 SNN       Discard top                    [9,3,2]         {0:9}
 TNST      Print as integer               [9,3]           {0:9}           2
                                                                                error
```
Program stops with an error: No exit found.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
```
ḋl
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@GO7pz//y3/RwEA "Brachylog – Try It Online")
### Explanation
```
ḋ        Prime decomposition
 l       Length
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), ~~8~~ 2 bytes
```
≢⍭
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/P@1R24RHnYse9a4FshUsudIUDM2AhLGJMZA0MrMwB1KmlgYmlgA "APL (Dyalog Extended) – Try It Online")
`⍭` finds factors, `≢` counts how many of them there are.
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 42 bytes
```
D,f,@,bUbU$^=
L,dVfbUG$XGRzGGXzÞ{f}bUbU0$:
```
[Try it online!](https://tio.run/##S0xJKSj4/99FJ03HQScpNClUJc6Wy0cnJSwtKdRdJcI9qMrdPaLq8LzqtFqQrIGK1X@VnMTcpJREBUM7ey7///8NzQA "Add++ – Try It Online")
I don't even know where to begin explaining this mess.
## Explained
```
D,f,@,bUbU$^=
D,f,@,        ; a helper function f that given a list [number, [x, y]]
      bUbU$^  ;   returns whether x ^ y
            = ;   equals number
L,dVfbUG$XGRzGGXzÞ{f}bUbU0$:
L,                            ; a lambda that
  dV                          ; places its input into the register
    fbU                       ; and gets the prime factor of the input. This is guaranteed to be a single item because the input is a prime raised to a power.
       G$X                    ; push a list of input copies of that power
          GRz                 ; and zip that with the range [1...input]
             GGX              ; also, push input copies of the input
                z             ; and zip that with our big list. I'm calling it a big list because it is what it is.
                 Þ{f}         ; filter that list based on the results of the helper function f
                     bUbU0$:  ; get the power out of the many nested lists returned.
```
[Answer]
# QBasic, ~~51~~ 41 bytes
```
INPUT n
FOR i=2TO n
f=f-(n/i=n\i)
NEXT
?f
```
-10 bytes by copying the approach from [Darren Smith's Nibbles answer](https://codegolf.stackexchange.com/a/240635/16766): For a prime power input, the desired output equals the number of integers between 1 (exclusive) and the input (inclusive) that evenly divide the input.
```
INPUT number
FOR testFactor = 2 TO number
  ' number is divisible by testFactor if their float division equals
  ' their int division
  isDivisible = (number / testFactor = number \ testFactor)
  ' Truthy is -1 in QBasic, so we subtract rather than add to the tally
  numFactors = numFactors - isDivisible
NEXT testFactor
PRINT numFactors
```
[Answer]
# [HBL](https://github.com/dloscutoff/hbl), 7 bytes
*(or possibly 6.5 depending on how [this meta question](https://codegolf.meta.stackexchange.com/q/24251/16766) shakes out)*
```
+(*'?(*%.(02.
```
[Try it!](https://dloscutoff.github.io/hbl/?f=0&p=KygqJz8oKiUuKC0yMC4_&a=ODE_)
### Explanation
```
+(*'?(*%.(
         (0    Inclusive range
           2    from 2
            .   to the argument
     (*        Map over each value x in that list:
       %.       Argument mod x
 (*            Map over each value in that list:
   '?           Logical negation
               The result is a list containing 1 for each number that divides
               the argument, 0 otherwise
+              Take its sum
```
[Answer]
# [Risky](https://github.com/Radvylf/risky), 3 bytes
```
!\?___
```
[Try it online!](https://radvylf.github.io/risky?p=WyIhXFw_X19fIiwiWzI1Nl0iLDBd)
---
A basically built-in solution for now, working on a non-trivial version (might not be possible given Risky's heavy investment in specific operators, and generally awful control flow).
```
!      Count
 \     Prime factors
  ?    Input
   ___ (Padding)
```
[Answer]
# [Nekomata](https://github.com/AlephAlpha/Nekomata), 1 byte
```
ƒ
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70iLzU7PzexJHFZtJJurlLsgqWlJWm6FouOTVpSnJRcDOUu2GzJZWjGZWxizGVkZmHOZWppYGIJkQIA)
`ƒ` factorizes the input number, and returns a list of unique prime factors and a list of exponents.
Only the top of the stack will be printed, which is the list of exponents. Since the input is a prime power, this will be a singleton list.
[Answer]
# Java 8, 59 bytes
A lambda from `int` to `int`.
```
x->{int f=1,c=0;while(x%++f>0);for(;x>1;c++)x/=f;return c;}
```
[Try It Online](https://tio.run/##XU7PT4MwFD7DX/EuJiV0FdycYoWjiQdPO5rF1K7FYldIWzYWwt@OnXIyecn73sv3q2Entmo7YZrD99z1n1px4Jo5B29MGRjjaHk6z3xYUhmmoQkq0nuliewN96o15GUBz6/Gi1pYDAuoQEI5D6tqVMaDLHPMy4yev5QWaLhJU1llCZWtRXSocsrTNBluS0mt8L01wOk0RzT@X@PUqgMcQ0O081aZ@n0PzNYuuRaOghmgaxhnTnzAExhxhnAH0lhgyLcY1ps1hrvt4wOG@yLbFNOfMtpdnBdH0vaedMHXa4MkYV2nL@jXLElooE1xmCmefwA)
[Answer]
# J, 4 bytes
```
#@q:
```
`q:` gives the list of prime factors, `#` gives the length of the list.
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/lR0Krf5rcnGlJmfkK6QpWCoYmikYmxgrGJlZmCuYWhqYWHJx/QcA "J – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 37 bytes
```
length(numbers::primeFactors(scan()))
```
[Try it online!](https://tio.run/##K/r/Pyc1L70kQyOvNDcptajYyqqgKDM31S0xuSS/qFijODkxT0NTU/O/oZHFfwA "R – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 3 bytes
```
Yfz
```
[Try it online!](https://tio.run/##y00syfn/PzKt6v9/U0sDE0sA "MATL – Try It Online")
### Explanation:
```
     % Implicit input: 59049
Yf   % Factorize input [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
  z  % Number of non-zero elements: 10
     % Implicit output
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~3~~ 2 bytes
```
Æḍ
```
[Try it online!](https://tio.run/##y0rNyan8//9w28Mdvf///ze1NDCxBAA "Jelly – Try It Online")
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `l`, 1 byte
```
ǐ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=l&code=%C7%90&inputs=9&header=&footer=)
-1 byte thx to @lyxal
Length of the prime factors, the flags are cheaty+awesome
[Answer]
# MS Excel, 33 bytes
An anonymous worksheet function that takes input from cell `A1` and outputs to the calling cell
```
-SUM(-(MOD(A1,SEQUENCE(A1))<1))-1
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `L`, 1 [byte](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
f
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPWYmZm9vdGVyPSZpbnB1dD01OTA0OSZmbGFncz1M)
Push the prime `f`actors of the input then take the `L`ength of the list.
[Answer]
# [Python 2](https://docs.python.org/2/), 62 bytes
```
def f(n,p=2,i=0):
	while n%p:p+=1
	while n>p**i:i+=1
	return i
```
[Try it online!](https://tio.run/##K6gsycjPM/r/PyU1TSFNI0@nwNZIJ9PWQNOKi7M8IzMnVSFPtcCqQNvWEM63K9DSyrTKBAsVpZaUFuUpZP4vKMrMKwEaYGxirPn/PwA "Python 2 – Try It Online")
Nothing fancy here.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 3 bytes
```
k l
```
[Try it online!](https://tio.run/##y0osKPn/P1sh5/9/U0sDE0sA "Japt – Try It Online")
## Explanation:
```
k l
k     Get the prime factors of the input
  l   Return the length
```
[Answer]
# [Actually](https://github.com/Mego/Seriously), 2 bytes
```
ol
```
[Try it online!](https://tio.run/##S0wuKU3Myan8/z8/5/9/U0sDE0sA "Actually – Try It Online")
]


[Question]
      [
You have two values each of which is either `0` representing "unknown", or one of `1,2,3`. Merge them into a single value as follows:
* If both values are nonzero and equal, output that value:
`(3,3) -> 3`
* If both values are nonzero but unequal, output 0 for unknown:
`(1,2) -> 0`
* If one value is zero and the other is not, output the nonzero value:
`(2,0) -> 2, (0,1) -> 1`
* If both values are zero, output zero:
`(0,0) -> 0`
**Test cases:**
There are 16 possible input pairs.
```
  | 0 1 2 3
--+--------
0 | 0 1 2 3
1 | 1 1 0 0
2 | 2 0 2 0
3 | 3 0 0 3
(0, 0) -> 0
(0, 1) -> 1
(0, 2) -> 2
(0, 3) -> 3
(1, 0) -> 1
(1, 1) -> 1
(1, 2) -> 0
(1, 3) -> 0
(2, 0) -> 2
(2, 1) -> 0
(2, 2) -> 2
(2, 3) -> 0
(3, 0) -> 3
(3, 1) -> 0
(3, 2) -> 0
(3, 3) -> 3
```
## Leaderboards
```
var QUESTION_ID=165314,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), ~~46~~ ~~43~~ 42 bytes
```
import StdEnv
?[a,b]|a<1||a==b=b=0
```
#
```
?o sort
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3PzO3IL@oRCG4JMU1r4zLPjpRJym2JtHGsKYm0dY2CQgN/geXJBaVcCkrpJXmJZdk5ucp2CrY5ysUA7Vx2SIEo410DGL//0tOy0lML/6v6@nz36UyLzE3M7kYAA)
Anonymous composition `:: [Int] -> Int`, sorts the pair and then matches off the first member.
Doing it as a composed lambda is the same length:
```
import StdEnv
```
#
```
(\[a,b]|a<1||a==b=b=0)o sort
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 6 bytes
```
×¬o=a»
```
[Try it online!](https://tio.run/##y0rNyan8///w9ENr8m0TD@3@//@/wX8jAA) or [Try all combinations!](https://tio.run/##ARsA5P9qZWxsef//w5fCrG89YcK7/zPFu8Onw75gR/8 "Jelly – Try It Online")
**How?**
```
×¬o=a»   Dyadic link
×        Multiply the two arguments.
 ¬       Logical not. Gives 1 if one argument is 0, 1 otherwise.
   =     Are the two arguments equal?
  o      Logical or the result of = and ¬.
     »   Greater of the two arguments.
    a    Logical and. Gives the greater of the two arguments if they are equal
         or if one of them is zero and gives 0 otherwise.
```
Using the method in the [APL answer](https://codegolf.stackexchange.com/a/165318/75553), we get the same byte count. One byte longer than that answer because lowest common multiple is two bytes.
**6 bytes**
```
«=æl×»
```
[Try it online!](https://tio.run/##ARwA4/9qZWxsef//wqs9w6Zsw5fCu/8zxbvDp8O@YEf/ "Jelly – Try It Online")
[Answer]
# TI-Basic, 10 bytes
```
max(Ans)not(prod(Ans)ΔList(Ans
```
Multiply maximum value by result of (some element equals zero OR elements are equal)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 22 bytes
```
f(x,y){x=x*y&2?0:x|y;}
```
[Try it online!](https://tio.run/##Rc5BDoIwFATQdXuKHwymlWoQXFGQs5hitYkWg5D0Bzl7LXbhapJ5sxi1vynlvWZOIJ9d43a4Ldq8ch@Ui98Yqx5Td4X6PXamP9zPlBo7wvNiLON0pkT3A7C1ctBALkPUcAqRZZySv2JUjIpRyWsIplmSTqlKBKwnALn4zUpooSyggmPOJV38Fw "C (gcc) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 27 bytes
```
a#b=max a b*0^(a*b*(a-b)^2)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P1E5yTY3sUIhUSFJyyBOI1ErSUsjUTdJM85I839uYmaegq1CbmKBb7xCQVFmXolCdDRQg0INULmNrkK0gZ6ecWxsTZKNLpT5HwA "Haskell – Try It Online")
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 28 bytes
```
@(a,b)~(a*b*(a~=b))*max(a,b)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999BI1EnSbNOI1ErSUsjsc42SVNTKzexAiz6Py2/SCHT1tDKWAfEygKzFFIyiws0ojN1snTSNICkZqymTmpeCgj/BwA "Octave – Try It Online")
or
```
@(a,b)(a==b|~(a*b))*max(a,b)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999BI1EnSVMj0dY2qaZOI1ErSVNTKzexAiz6Py2/SCHT1sDKWAfEygKzFFIyiws0ojN1snTSNICkZqymTmpeCgj/BwA "Octave – Try It Online")
---
### Explanation:
The maximum value should be outputted if `a*b=0` or if `a==b`. The function takes `a` and `b` as inputs. It multiplies `a*b`, thus getting a zero if one of them is zero, and checks that `a~=b`, thus getting a zero if the two are equal. We negate both, so that both conditions gives us a truthy value telling us that we should output the maximum value. We then multiply this boolean (`0/1`) by the maximum value, and outputs it.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
```
`α*P_*Z
```
[Try it online!](https://tio.run/##MzBNTDJM/W98eO7hxWWVlZX/E85t1AqI14r6X6l0eL@Crp3C4f1KOjH/AQ "05AB1E – Try It Online")
**Explanation**
```
`α        # absolute difference of the inputs
  *       # multiplied by the inputs
   P      # product of the result
    _     # logically negated
     *    # multiplied by the inputs
      Z   # max
```
[Answer]
# JavaScript (ES6)
## 27 bytes
A rather long formula, but without any conditional statement.
```
a=>b=>(a|4)*(b|4)*6%61%27&3
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i7J1k4jscZEU0sjCUSaqZoZqhqZqxn/T87PK87PSdXLyU/X4FJQiDbQMdQx0jGO1ctNLNBIVLC1AwqiCycBhRXSNBI1NZI0NfWy8jPzNNQV1DWBKmG8mDwgV/M/AA "JavaScript (Node.js) – Try It Online")
## 17 bytes
Simply a port of [Dennis' method](https://codegolf.stackexchange.com/a/165326/58563).
```
a=>b=>a*b&2?0:a|b
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i7J1i5RK0nNyN7AKrEm6X9yfl5xfk6qXk5@ugaXgkK0gY6hjpGOcaxebmKBRqKCrR1QEF04CSiskKaRqKmRpKmpl5WfmaehrqCuCVQJ48XkAbma/wE "JavaScript (Node.js) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~12~~ 9 bytes
Takes input as an array of integers.
```
×&2?0:Ur|
```
[Try it online!](https://tio.run/##y0osKPn///B0NSN7A6vQopr//6MNdAxjAQ "Japt – Try It Online")
[Answer]
# [Elixir](https://elixir-lang.org/), 34 bytes
Pretty simple in a functional programming language, just get the first match. No maths here!
```
fn a,a->a
a,0->a
0,a->a
_,_->0 end
```
[Try it online!](https://tio.run/##VY6xCgMhEER7v2KxWsET8wGxT5UibUDkshFBjHh7kOL@3XgJhKQa5jE8hnJ6ptYjsU@lrgxHuBeYHJzOZsAFpVSwObhwSyWaRjWHmTy3kPIAKK9Favgf8WO4mCI1VEDlJrAPZ9BhckEEbfewn@a1n5zdR10Z/L4wqDT8NiW296VUlkozo@pWHF4 "Elixir – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 35 bytes
```
rep(unique(sort(c(0,scan()))),4)[4]
```
[Try it online!](https://tio.run/##K/r/vyi1QKM0L7OwNFWjOL@oRCNZw0CnODkxT0MTCHRMNKNNYv8bKxj8BwA "R – Try It Online")
Shameless port of [Sok's well-explained Pyth answer](https://codegolf.stackexchange.com/a/165434/80010).
[Answer]
# [Befunge-93](https://github.com/catseye/Befunge-93), 20 bytes
```
&::&*#v_&+.@
@.*!-&<
```
[Try it online!](https://tio.run/##S0pNK81LT/3/X83KSk1LuSxeTVvPgctBT0tRV83m/39jBWMA "Befunge-93 – Try It Online")
## Explanation
this boils down to:
```
if(A * B = 0) {
    output (A + B)
    end
} else {
    output A * (A = B)
    end
}
```
[Answer]
# [Python 3](https://docs.python.org/3/), 30 bytes
```
lambda a,b:0==a*b*(a-b)and a|b
```
[Try it online!](https://tio.run/##XcxBCsIwFATQfU4xZJP8mkC1rgq5STc/tNEU/S2lG6F3j2gVxIHZvZn5sV4naUoKXbnxPfYMdrGtQ@AqVpZ9JJYevMUyL1lWq4ENNY44oenE@4P/RJNSaVqQkQULy2WwZ2oV9tm75PQG7QbpgzGk8OLjH//xyWY3Eu0ehvA9o/IE "Python 3 – Try It Online")
-5 bytes thanks to Oliver
-1 byte thanks to Jo King
[Answer]
# [Befunge-93](https://github.com/catseye/Befunge-93), 17 bytes
```
&::&-!_&*!\&+*.@.
```
[Try it online!](https://tio.run/##S0pNK81LT/3/X83KSk1XMV5NSzFGTVtLz0Hv/39DBQMA "Befunge-93 – Try It Online")
As psuedo-code:
```
f(a,b):
  if a-b==0:
    print(b)
  else:
    print((!(a*b))*(a+b))
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~20~~ 18 bytes
-2 bytes thanks to Martin Ender.
```
(.)\1|0
$1
..|^$
0
```
[Try it online!](https://tio.run/##BcGhDYBAEERR/@uA5DCXmd0iaIIQEAgMgiCv9@W99/ru56y5rUe1vmweYjK9j31CVRIyCpRY2DhwEiJMBJGkSJNB5g8 "Retina 0.8.2 – Try It Online")
[Answer]
# **JavaScript, 24 Bytes**
```
x=>y=>!x*y|!y*x|(x==y)*x
```
Allows all numbers, no conditional, doesn't require sorted input
[Answer]
# Python 2, ~~42~~ 34 bytes
```
lambda a,b:(0in(a,b)or a==b)*(a|b)
```
EDIT: -8 thanks to @TIO and @JonathanAllan
[Answer]
# [Shakespeare Programming Language](https://github.com/TryItOnline/spl), ~~216~~ 208 bytes
```
,.Ajax,.Ford,.Act I:.Scene I:.[Enter Ajax and Ford]Ajax:Listen tothy!Ford:Listen tothy!Am I as bad as you?If soyou zero.Is the product ofyou I worse a cat?If soyou be the sum ofyou I.If notyou zero.Open heart
```
[Try it online!](https://tio.run/##VY0xC8IwEIV3f8VzL4GuXaSDQkBwcBSHtLlSxeZKckHrn4@JoOJ079777l6YbylVqr2aR6V27G3WvUA36tiToyJOWyfkURAYZ1Goc9ma/SUIOQjLuKyL/e@0EzRMQGdsGQvHjR4QOAs8ybPSATISZs825lIeSqJxZx8IBr2R30FHbzbE6cOpnDmW77fDnJtHMl5Sqlf1Cw "Shakespeare Programming Language – Try It Online")
As psuedo-code:
```
f(a,b):
  if a==b:
    b=0
  if a*b<1:
    b=a+b
  else:
    b=0
  return b
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 27 bytes
```
N+N+N.
N+0+N.
0+N+N.
_+_+0.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/308bCPW4/LQNQJQBhBevHa9toPffXlfBACgepKNQXpRZkpqmoaRaoKCkoxAdFKupxwWWNcQra4RX1hhVNiYPWdoQr8WGeC02xGuxIX6LjfBabITXYiO8Fhvht9gYr8XGeC02xmuxMbrFcNn/AA "Prolog (SWI) – Try It Online")
The most naive translation ever.
[Answer]
# [Glee](https://withglee.com/Frames/GFMain.htm), ~~24~~ ~~22~~ 20 bytes
Idea to append zero taken from Sok’s [Pyth solution](https://codegolf.stackexchange.com/a/165434/39407).
`~~=>n,0& \*>0\+ >1~ \*n\>>~~`
```
=>n,0& *>0\+ <2*n\>>             $$<2 instead of >1~ (not > 1)
```
Explanation:
```
a b=>n,0& *>0\+ <2*n\>>
a b=>n                      3 1     2 2     0 3     0 0     assign a b to n
      ,0                    3 1 0   2 2 0   0 3 3   0 0 0   catenate 0
        &                   0 1 3   0 2     0 3     0       unique elements
          *>0               011     01      01      0       mark all > 0 (boolean)
             \+             2       1       1       0       reduce by addition
                <2          0       1       1       1       result <2 ?
                  *n        0 0     2 2     0 3     0 0     multiply with n
                    \>>     0       2       3       0       largest element
```
Old version
```
=>n--[2]=0|(n\* =0)*n\>>
```
Explanation for a pair of numbers (a b):
```
                              result for a b pairs
                               3 1    2 2    0 3
a b=>n--[2]=0|(n\* =0)*n\>>
a b                            3 1    2 2    0 3   create vector (a b)
   =>n                                             assign vector to n
      --                       0 _2   0 0    0 3   calculate the first difference vector of n (monadic --)
        [2]=0                  0      1      0     result vector at index 2 equal to 0 ? (boolean)
              (n\*             3      4      0     n reduced by multiplication
                   =0)         0      0      1     equal to 0 ? (boolean)
             |                 0      1      1     OR (boolean) (dyadic |)
                      *n       0 0    2 2    0 3   multiplied by n (dyadic *)
                        \>>    0      2      3     largest element (monadic \>>)
```
[Answer]
# [QBasic 1.1](http://www.qbasic.net/), 38 bytes
```
INPUT A,B
IF A*B THEN?A*-(A=B)ELSE?A+B
```
-1 thanks to [DLosc](https://codegolf.stackexchange.com/users/16766/dlosc).
Input is two comma-separated integers.
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 32 bytes
```
{If[_=_2,_,If[Min!__,0,Max!__]]}
```
[Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@7/aMy063jbeSCdeB8jyzcxTjI/XMdDxTawAMmJja//7paamFEerFBQkp8dyBRRl5pWEpBaXOCcWpxZHq6XpKLjlJJZE@5eWpBZFh@koGFgZg4lYHQXD2Nj/AA "Attache – Try It Online")
Takes input as two arguments, such as `f[0, 1] = 1`.
## Other solutions
## 34 bytes
```
{If[Same!_,_@0,If[Min!_,0,Max!_]]}
```
[Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@7/aMy06ODE3VTFeJ97BQAfI883MA3IMdHwTKxTjY2Nr//ulpqYUR6sUFCSnx3IFFGXmlYSkFpc4JxanFken6Si45SSWRPuXlqQWRYfpKBhYGYOJWB0Fw9jY/wA "Attache – Try It Online") The same as above, but takes input as an array
## 39 bytes
```
{ToBase[47483073034,5][FromBase&4!_]-1}
```
[Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@786JN8psTg12sTcxMLYwNzYwNhExzQ22q0oPxckrmaiGB@ra1j73y81NaU4WqWgIDk9liugKDOvJCS1uMQZqKQ4Ok1HwS0nsSTav7QktSg6TEfBwMoYTMTqKBjGxv4HAA "Attache – Try It Online")
Hardcodes the solution in a base-5 integer. More interesting IMO but longer.
[Answer]
# Pyth, 11 bytes
```
e+Z.-+xFQQ{
```
[Try it here](https://pyth.herokuapp.com/?code=e%2BZ.-%2BxFQQ%7B&test_suite=1&test_suite_input=0%2C%200%0A0%2C%201%0A0%2C%202%0A0%2C%203%0A1%2C%200%0A1%2C%201%0A1%2C%202%0A1%2C%203%0A2%2C%200%0A2%2C%201%0A2%2C%202%0A2%2C%203%0A3%2C%200%0A3%2C%201%0A3%2C%202%0A3%2C%203&debug=0)
### Explanation
```
e+Z.-+xFQQ{
     +xFQQ      Prepend the XOR of the inputs to the inputs.
   .-     {Q    Remove one copy of the deduplicated (implicit) input.
 +Z             Prepend 0.
e               Take the last.
```
### Alternative solution, 11 bytes
```
e+0.-F{B+xF
```
[Answer]
# [Pyth](https://pyth.readthedocs.io), 10 bytes
```
-iFQ&.AQnF
```
[Try it online!](http://pyth.herokuapp.com/?code=-iFQ%26.AQnF&input=%280%2C+0%29+-%3E+0%0A%280%2C+1%29+-%3E+1%0A%280%2C+2%29+-%3E+2%0A%280%2C+3%29+-%3E+3%0A%281%2C+0%29+-%3E+1%0A%281%2C+1%29+-%3E+1%0A%281%2C+2%29+-%3E+0%0A%281%2C+3%29+-%3E+0%0A%282%2C+0%29+-%3E+2%0A%282%2C+1%29+-%3E+0%0A%282%2C+2%29+-%3E+2%0A%282%2C+3%29+-%3E+0%0A%283%2C+0%29+-%3E+3%0A%283%2C+1%29+-%3E+0%0A%283%2C+2%29+-%3E+0%0A%283%2C+3%29+-%3E+3&test_suite=1&test_suite_input=0%2C+0%0A%0A0%2C+1%0A%0A0%2C+2%0A%0A0%2C+3%0A%0A1%2C+0%0A%0A1%2C+1%0A%0A1%2C+2%0A%0A1%2C+3%0A%0A2%2C+0%0A%0A2%2C+1%0A%0A2%2C+2%0A%0A2%2C+3%0A%0A3%2C+0%0A%0A3%2C+1%0A%0A3%2C+2%0A%0A3%2C+3%0A&debug=0&input_size=2)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 20 bytes
```
a=>b=>a-b&&a*b?0:a|b
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i7J1i5RN0lNLVEryd7AKrEm6X9yfl5xfk6qXk5@ukaahoEmEGlyoQoa4RA0xCZohCFogE3QEJsgVu3G2Gw3xma7MQ7txticZIzNScbYnGSMw8z/AA "JavaScript (Node.js) – Try It Online")
[Answer]
# 12-basic, 36 bytes
```
FUNC M(A,B)?(A or B)*(!A~!B|A==B)END
```
This can probably be shortened.
`~` is bitwise XOR (as well as bitwise NOT when used as a unary operator) (Just like in Lua)
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 28 bytes
```
[pq]sqsidli=qd0rli*0!=qli++p
```
[Try it online!](https://tio.run/##S0n@b6xg@D@6oDC2uLA4MyUn07YwxaAoJ1PLQNG2MCdTW7vg/38A "dc – Try It Online")
I'll keep mulling over this, it feels like it must be golfable. `[pq]sq` just makes a print & quit macro. `sidli` stores one of our values in the register `i`, duplicates the other value, and then recalls `i`. `=q` consumes two values on the stack, and executes macro `q` if they're equal (so, prints the one value left behind). `d0r` duplicates the value on the stack again, and then puts a `0` on the stack in between them. `li*0!=` loads `i`, multiplies the two values, and runs `q` to print the `0` that we left on the stack if the two values were not equal. If none of these things has happened yet, we `li` to load `i`, and we now have three values on the stack - two zeroes and our one non-zero value. `++` add the three together, and `p`rint.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 25 bytes
```
/ /;$_=($'|$`)>>($'*$`&2)
```
[Try it online!](https://tio.run/##K0gtyjH9/19fQd9aJd5WQ0W9RiVB084OyNBSSVAz0vz/30jB6F9@QUlmfl7xf90CAA "Perl 5 – Try It Online")
Steals the method from @Dennis's Python answer.
[Answer]
# [Tcl](http://tcl.tk/), 43 bytes
```
proc M a\ b {expr !$a?$b:!$b?$a:$a-$b?0:$a}
```
[Try it online!](https://tio.run/##LcoxCsMwDIXhPad4AQ0ttGBLm5ecICdoMsghW0pNmkIh@OzuGzr8PH2gY9laK/trwQifkHGu37KjFx8kp17yIJ7E7zwCt7bt6eX/2QUEFpky6yId6UhHWmmllVbaaKONNrriLJ/jjYv4TfI1TXiMEIfkubYf "Tcl – Try It Online")
[Answer]
# **PHP - 52 bytes**
```
<?=($a=$argv[1])==($b=$argv[2])?$a:($a*$b?0:$a|$b);
```
[Try it online!](https://tio.run/##K8go@P/fxt5WQyXRViWxKL0s2jBW0xbITYJyjWI17VUSrYDyWipJ9gZWKok1Kkma1lz///83/m/8L7@gJDM/r/i/bopCcUZ@UUl8fkFqXnxJYrptfh4A "PHP – Try It Online")
Explanation:
```
$a==$b  Check for equality, display first value if equal
$a*$b   If multiplication equates to non-zero, display 0 (Unknown) else...
$a|$b   Display the non-zero value.
```
]