[Question]
  [
Draw the parabolic trajectory of a thrown ball. 
The input is the ball's initial upward velocity, a positive integer `v`. Every second, the ball moves `1` space right and `v` spaces vertically, and then `v` decreases by `1` to due to gravity. So, the upward velocity eventually steps down from `v` to `0` and down to `-v`, finally falling back down to its initial height.
The ball's positions trace a parabola. At horizontal position `x`, its height is `y=x*(2*v+1-x)/2`, with `(0,0)` the ball's initial position at the bottom left.
Output ASCII art of the ball's trajectory with `O`'s on the coordinates it ever occupies. The output should be a single multi-line piece of text, not an animation of the path over time.
The output should have no leading newlines and at most one trailing newline. The bottom line should be flush with the left edge of the screen, i.e. have no extra leading spaces. Trailing spaces are OK. You may assume the output line width fits in the output terminal.
v=1
```
 OO 
O  O
```
v=2
```
  OO  
 O  O 
O    O
```
v=3
```
   OO   
  O  O  
 O    O 
O      O
```
v=4
```
    OO    
   O  O   
  O    O  
 O      O 
O        O
```
v=10
```
          OO          
         O  O         
        O    O        
       O      O       
      O        O      
     O          O     
    O            O    
   O              O   
  O                O  
 O                  O 
O                    O
```
Related: [Bouncing ball simulation](https://codegolf.stackexchange.com/q/10520/20260)
---
**Leaderboard:**
```
var QUESTION_ID=111861,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/111861/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]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~18~~ ~~16~~ 13 bytes
-3 bytes thanks to [@Neil](https://codegolf.stackexchange.com/users/17602/neil)!
```
Ｆ⊕Ｎ«←OＭ⊕ι↓»‖Ｃ
```
## Explanation
```
Ｆ⊕Ｎ«        »    For ι (implicitly from 0) to (1 + input as number)
       ←O          Print O, with print direction rotated 180 degrees
         Ｍ⊕ι↓     Move 1+ ι units down
               
                ‖Ｃ Reflect (in the default direction, right), leaving original intact
```
[Try it online!](https://tio.run/nexus/charcoal#ASwA0///77ym4oCmwrfCueKBuu@8rsK5wqtP77ytzrnihpPCu@KAlu@8o@KGkP//NQ "Charcoal – Try It Online") Link is to verbose code.
[Answer]
# C, ~~93~~ 92
(Note, someone got to 87 in the comments)
```
y,n;f(s){for(y=0;y<=s;){printf("%*c%*c",s-y+1,79,y*2+1,79);for(n=++y;s+1-n&&n--;)puts("");}}
```
[Try it online!](https://tio.run/nexus/c-gcc#HYyxCsMgFAD3fIUIDb6oYLqU8OrHBIk0Q1@CmkHEz@5sbeGGW@5aVoReRCj@CCJbg/lpI0I5w07JC36bXIerqLOc1WNRebr/BfBXkJUyY5SzpnEkrRHOK0XBOWCtrS/Ye91JQBkY82I2gF3Clq5AzOBQ24cO7Vb32r4)
---
Readable:
```
y,n;f(s){
    for(y=0;y<=s;){
        printf("%*c%*c",s-y+1,79,y*2+1,79);
        for(n=++y;s+1-n&&n--;)puts("");
    }
}
```
---
[Answer]
# [Python 2](https://docs.python.org/2/), 65 bytes
```
f=lambda n,x=0:(n and f(n-1,x+1)or'')+'\n'*n+' '*x+'O'+'  '*n+'O'
```
[Try it online!](https://tio.run/nexus/python2#@59mm5OYm5SSqJCnU2FrYKWRp5CYl6KQppGna6hToW2omV@krq6prR6Tp66Vp62uoK5Voa3urw5kKYAF/NX/FxRl5pUAdRgaaP43NAAA "Python 2 – TIO Nexus")
[Answer]
# GNU sed, 41
* Score includes +1 from `-r` flags to sed.
```
s/$/OO/
:
s/(\s*) O( *)O$/&\n\1O \2 O/
t
```
Input is in unary, as a string of spaces - the length of string is the input.
[Try it online](https://tio.run/nexus/bash#HclBDsIgEEbhPaf4FygtiUFqVzaeYS4wO6Gxm8EwDSvvjk3f7stbS0XDJoiY8MCMeF@QisFRfn8K2su2U9@6yb7CXbyyONiGHzQn3Cpc12ADUTBPo2Fg9SNogB/JhisLRwJPOPbenUlFcv8D).
[Answer]
# Python 2, 76 bytes
```
x=input()
for i in range(x):print' '*(x-i),'O'+' '*i*2+'O'+'\n'*(i-x+1and i)
```
Pretty simple. The `i-x+1and i` is to prevent a bunch of trailing newlines.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~18~~ 14 bytes
Saved 4 bytes thanks to *Adnan*
```
ƒ¶N×'ONúRÂJ}.c
```
[Try it online!](https://tio.run/nexus/05ab1e#@39s0qFtfoenq/v7Hd4VdLjJq1Yv@f9/QwMA "05AB1E – TIO Nexus")
**Explanation**
```
ƒ                   # for N in [0 ... input]
 ¶N×                # push N newlines
    'O              # push "O"
      Nú            # pad with N spaces in front
        RÂ          # reverese and create a reversed copy
          J         # join everything to a string
           }        # end loop
            .c      # pad lines until centered 
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 76 bytes
```
for((n=$1+1;--n;));{
yes ''|head -$n
r=$r›${n}AO
t=›${n}BO$t
}
echo O${r}O$t
```
Only works in a terminal since it uses [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code). `›` represents the CSI byte (**0x9b**).
### Test run
```
$ # The terminal's encoding must be set to ISO-8859-1.
$
$ xxd -g 1 arc.sh
0000000: 66 6f 72 28 28 6e 3d 24 31 2b 31 3b 2d 2d 6e 3b  for((n=$1+1;--n;
0000010: 29 29 3b 7b 0a 79 65 73 20 27 27 7c 68 65 61 64  ));{.yes ''|head
0000020: 20 2d 24 6e 0a 72 3d 24 72 9b 24 7b 6e 7d 41 4f   -$n.r=$r.${n}AO
0000030: 0a 74 3d 9b 24 7b 6e 7d 42 4f 24 74 0a 7d 0a 65  .t=.${n}BO$t.}.e
0000040: 63 68 6f 20 4f 24 7b 72 7d 4f 24 74              cho O${r}O$t
$
$ bash arc.sh 1
 OO
O  O
$ bash arc.sh 2
  OO
 O  O
O    O
$ bash arc.sh 3
   OO
  O  O
 O    O
O      O
$ bash arc.sh 4
    OO
   O  O
  O    O
 O      O
O        O
```
[Answer]
# JavaScript (ES6), ~~98~~ ~~92~~ ~~89~~ ~~84~~ 78 bytes
*(-20 bytes thanks to Arnauld!)*
```
f=(v,i=0)=>i>v?"":" "[r="repeat"](v-i)+0+" "[r](2*i)+0+`
`[r](i++<v&&i)+f(v,i)
```
A recursive solution. This is also my first *ever* answer in JavaScript, so please be gentle! I am still learning all this neat language has to offer, so golfing tips are very much appreciated. :)
## Test Snippet
You may need to scroll to see the entire output.
```
f=(v,i=0)=>i>v?"":" "[r="repeat"](v-i)+0+" "[r](2*i)+0+`
`[r](i++<v&&i)+f(v,i)
```
```
<input id=i min=1 type=number><button onclick=alert(f(document.getElementById("i").value))>Submit</button>
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~19~~ 17 bytes
```
Q:tqYsQ79Z?PtPv!c
```
Try it at [MATL Online!](https://matl.io/?code=Q%3AtqYsQ79Z%3FPtPv%21c&inputs=4&version=19.8.0) Or [verify all test cases](https://tio.run/nexus/matl#S/gfaFVSGFkcaG4ZZR9QElCmmPzfJeS/IZcRlzGXCZehAQA).
### Explanation
```
Q        % Implicitly input v. Add 1
:        % Push [1 2 ... v+1]
tq       % Duplicate and subtract 1: pushes [0 1 ... v]]
Ys       % Cumulative sum: gives [0 1 3 6 ...]
Q        % Add 1: gives [1 2 4 7 ...]
79       % Push 79 (ASCII for 'O')
Z?       % Create sparse matrix from column indices [1 2 3 4 ...],
         % row indices [1 2 4 7 ...], and data 79
P        % Flip vertically
tP       % Duplicate, flip vertically
v        % Concatenate the two matrices vertically
!        % Transpose
c        % Convert to char. Implicitly display. Char 0 is shown as space
```
[Answer]
# [RProgN 2](https://github.com/TehFlaminTaco/RProgN-2), 37 bytes
```
x=0xR{y@xy-` *`o` y2**`o...2y{[` };};
```
Getting in with my kind-of-golfy language before the proper golfy langauges jump in.
## Explained
```
x=              # Set 'x' to the input
0xR{            # For everything between the input and 0
    y@          # Set the iteration value to y, for this function only.
    xy-` *      # Subtract y from x, repeat the string " " that many times.
    `o          # Push an "o" to the stack.
    ` y2**      # Push 2*y " "'s to the stack
    `o          # Push another "o" to the stack
    ...         # Concatenate the parts of this string together, giving us the two balls.
    2y{[` };    # For all numbers between 2 and y, add a newline.
};              #
```
[Try it online!](https://tio.run/nexus/rprogn-2#@19ha1ARVF3pUFGpm6CglZCfoFBppAWk9fT0jCqroxMUaq1rrf///28OAA "RProgN 2 – TIO Nexus")
[Answer]
## Retina, ~~29~~ 19 bytes
```
 ?
$.`$*¶$&$'O$`$`O
```
[Try it online!](https://tio.run/nexus/retina#@69gz6Wil6CidWibipqKur9KgkqC////CiAAAA "Retina – TIO Nexus")
Takes input in unary as a run of spaces. Port of my JavaScript answer. Edit: Saved 10 bytes thanks to @MartinEnder♦.
[Answer]
# Retina, 35
* 2 bytes saved thanks to @MartinEnder
Port of [my sed answer](https://codegolf.stackexchange.com/a/111866/11259):
```
.+
$* OO
+`(\s*) (O *)O$
$&¶$1O $2 O
```
[Try it online](https://tio.run/nexus/retina#U9VwT/ivp82loqXg78@lnaARU6ylqaDhr6Cl6a/CpaJ2aJuKoYqRgoL//@AElf@GXEZcxlwmXIYGAA).
[Answer]
# R, 89 bytes
```
a=2*v+3
x=matrix(" ",a,v^2+1)
for(k in 0:v)x[c(1-k,k+2)+v,k^2+1]="o"
x[a,]="\n"
cat(x,sep="")
```
* Create a matrix of spaces (the variable a is the width of this matrix, saving a couple of bytes)
* Fill in "o"s at the required locations, working from the top of the arc downwards and outwards
* Add a newline at the end of each matrix row
* Collapse the matrix down to a single string and print
This is my first attempt at golfing, comments welcome...
[Answer]
# [Röda](http://github.com/fergusq/roda), ~~53~~ 52 bytes
```
f n{seq 0,n|{|i|["
"*i," "*(n-i),"O"," "*i*2,"O"]}_}
```
[Try it online!](https://tio.run/nexus/roda#@5@mkFddnFqoYKCTV1Ndk1kTrcSlpJWpo6SgpKWRp5upqaPkrwTmZWoZgdixtfG1/3MTM/MUqrk40zRMNblq/wMA "Röda – TIO Nexus")
Usage: `main { f(5) }`
Ungolfed version:
```
function f(n) {
    seq(0, n) | for i do
        push("\n"*i, " "*(n-i), "O", " "*i*2, "O")
    done
}
```
[Answer]
# Befunge, ~~75~~ 73 bytes
```
<vp00:&
1<-1_:v#\+55:g01\-g01g00" O"1\*2g01" O"1p0
#@_\:v>$$:!
1\,:\_^#:-
```
[Try it online!](http://befunge.tryitonline.net/#code=PHZwMDA6JgoxPC0xXzp2I1wrNTU6ZzAxXC1nMDFnMDAiIE8iMVwqMmcwMSIgTyIxcDAKI0BfXDp2PiQkOiEKMVwsOlxfXiM6LQ&input=NA)
The first line reads in the velocity, *v*, and saves a copy in memory. The second line then counts down from *v* to zero, with the index *i*, and on each iteration pushes a sequence of character/length pairs onto the stack.
```
Length  Character
-----------------
1       'O'
i*2     ' '
1       'O'
v-i     ' '
i       LINEFEED
```
This sequence represents a kind of run-length encoding of the required output in reverse. The last two lines then simply pop these character/length pairs off the stack, outputting *length* occurrences of each *character*, until the stack is empty.
[Answer]
# Java 8, ~~129~~ ~~124~~ 109 bytes
Golfed:
```
v->{String s="",t="";for(int j,y=0;y<=v;++y){for(j=0;j<v;++j)s+=j<y?"\n":" ";s+="o"+t+"o";t+="  ";}return s;}
```
[Try it online!](https://tio.run/nexus/java-openjdk#jZFBT4QwEIXv/IqXniCsRC8ehF2zxph48rDe1ENFupZ0C2lLDTH89nVgAdF4sJdp@r6@N5k51s2rkjlyxa3FreEfj@/F1uQPYnvDlcJnEAAjYx13VHwl33DgUoc7Z6TeP72Am72NiAUdURmEUjtIrHGRUslwmSKO5UQAu9a64pBUjUtqsnBKhyL0ONvMBDGDOSy5MLaCG2o6y3NMuUJL2nlKJVvD91FttDAa2fIEldTOwJQ/GVBSvO6xjIyuwZ41wxUYWJQusC749YFVDDF1F/e3JekGFVg8fn82hWuMhp20DivIaE76Yz7/0Hr7btiXkZ67YlrYOEkRltzzpHFSJaLRuZOVTu61uxvv2YnbQFAvNFg/DWhsViS8rlUb@iGuC7rgePwC)
Ungolfed:
```
public class DrawTheArcOfABall {
  public static void main(String[] args) {
    for (int i = 1; i < 6; ++i) {
      System.out.println(f(v -> {
        String s = "", t = "";
        for (int j, y = 0; y <= v; ++y) {
          for (j = 0; j < v; ++j) {
            s += (j < y ? "\n" : " ");
          }
          s += "o" + t + "o";
          t += "  ";
        }
        return s;
      } , i));
      System.out.println();
      System.out.println();
    }
  }
  private static String f(java.util.function.IntFunction<String> f, int v) {
    return f.apply(v);
  }
}
```
[Answer]
## Haskell, 69 bytes
```
r=replicate
f n=[0..n]>>= \a->r a '\n'++r(n-a)' '++'O':r(2*a)' '++"O"
```
Usage example: `f 3` -> `" OO\n O O\n\n O O\n\n\nO O"`. [Try it online!](https://tio.run/nexus/haskell#@19kW5RakJOZnFiSypWmkGcbbaCnlxdrZ2erEJOoa1ekkKigHpOnrq1dpJGnm6iprgBkqvurWxVpGGlBuUr@Sv9zEzPzFGwVCkpLgkuKfPIUVBTSFEz@AwA "Haskell – TIO Nexus").
[Answer]
# VBA, ~~124~~ ~~112~~ ~~85~~ ~~88~~ ~~66~~ ~~63~~ 59 bytes
```
For i=0To[A1]:?Space([A1]-i)"O"Space(2*i)"O"String(i,vbCr):Next
```
Saved 29 bytes in total thanks to Taylor Scott
This must be run the in VBA Immediate window and print the result in the same.
Expanded / Formatted, it becomes:
```
For i=0 To [A1]
   Debug.Print Space([A1]-i) & "O" & Space(2*i) & "O" & String(i,vbCr)
Next
```
(It turns out that concatenation in a print command is automatic without an operator.)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~18~~ 13 bytes
```
ÝηROÂ«ð×'O«ζ»
```
[Try it online!](https://tio.run/##ASEA3v8wNWFiMWX//8OdzrdST8OCwqvDsMOXJ0/Cq862wrv//zI "05AB1E – Try It Online")
```
Ý                # [0..n]
 €LRO            # [0.sum(), 0..1.sum(), ..., 0..n-1.sum(), 0..n.sum()]
     Â«          # Mirror image the array [0, 0..n.sum(), 0]
       ð×'O«     # Push that many spaces with an O appended to it.
            .B   # Pad small elements with spaces to equal largest element length.
              ø» # Transpose and print.
```
[Answer]
# MATLAB, 114 Bytes
```
function p(v),for i=0:v,fprintf([repmat(' ',1,v-i),'o',repmat(' ',1,2*i),'o',repmat('\n',1,(i*(i~=v)+1))]);end,end
```
ungolfed:
```
function p(v)
   for i=0:v
       fprintf([repmat(' ',1,v-i),'o',repmat(' ',1,2*i),'o',repmat('\n',1,(i*(i~=v)+1))]);
   end
end
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~17~~ 16 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
‘Ḷ+\Ṛ⁶ẋ;€”Om0z⁶Y
```
**[Try it online!](https://tio.run/nexus/jelly#@/@oYcbDHdu0Yx7unPWocdvDXd3Wj5rWPGqY659rUAUUiPz//78pAA)**
### How?
```
‘Ḷ+\Ṛ⁶ẋ;€”Om0z⁶Y - Main link: v         e.g. 3
‘                - increment: v+1            4
 Ḷ               - lowered range             [0,1,2,3]
  +\             - reduce with addition      [0,1,3,6]
    Ṛ            - reverse                   [6,3,1,0]
     ⁶           - a space                   ' '
      ẋ          - repeat (vectorises)       ['      ','   ',' ','']
       ;€        - concatenate each with
         ”O      -     an 'O'                ['      O','   O',' O','O']
           m0    - concatenate reflection    ['      O','   O',' O','O','O','O ','O   ','O      ']
             z⁶  - transpose with space fill ['   OO   ','  O  O  ','        ',' O    O ','        ','        ','O      O']
               Y - join with line feeds      ['   OO   \n  O  O  \n        \n O    O \n        \n        \nO      O']
                 - implicit print
```
[Answer]
# PHP, 76 bytes
```
for(;$argn>=0;$s.="  ")echo($r=str_repeat)("
",$i++),$r(" ",$argn--),o,$s,o;
```
Run with `echo <v> | php -nR '<code>'` or [test it online](http://sandbox.onlinephpfunctions.com/code/308cb432f2f510679934cd7370608ca05c5656bf).
loops `$argn` down from input to `0` and `$i` up from 0;  
prints - in that order - in each iteration
* `$i` newlines (none in the first iteration)
* left padding: `$argn` spaces
* left ball: `o`
* inner padding: `2*$i` spaces
* right ball: `o`
[Answer]
# [V](https://github.com/DJMcMayhem/V), ~~23~~ 19 bytes
```
2éoÀñYço/^2á O
HPJ>
```
[Try it online!](https://tio.run/nexus/v#@290eGX@4YbDGyMPL8/XjzM6vFDBn8sjwMvu////xgA "V – TIO Nexus")
Explain
```
2éo            " Insert two 'o's
   Àñ          " <Arg> times repeat
     Y         " Yank the current (top) line.  This is always '\s*oo'
      ço/      " On every line that matches 'o'
         ^     " Go to the first non-whitespace character (the 'o')
          2á   " Append two spaces (between the two 'o's
             O " Add a blank line on top of the current one
H              " Go to the first line
 P             " Paste in front ('\s*oo')
  J            " Join this line with the blank line immediately after it
   >           " Indent once
```
[Answer]
## JavaScript (ES6), 87 bytes
```
f=
n=>' '.repeat(n+1).replace(/./g,"$`#$'O$`$`O").replace(/ *#/g,s=>[...s].fill``.join`
`)
```
```
<input type=number min=0 oninput=o.textContent=f(+this.value)><pre id=o>
```
Nonrecursive solution. Indexing requirement was annoying, both in the above and the following 62-byte (I don't know whether it would result in a shorter Retina port) recursive solution:
```
f=n=>~n?` `.repeat(n)+`OO`+f(n-1).replace(/^ *O/gm,`
$&  `):``
```
[Answer]
## [Perl 5](https://www.perl.org/), 48 bytes
**47 bytes code + 1 for `-n`.**
```
$_++;print$/x$-,$"x$_,O,$"x($-++*2),O while$_--
```
[Try it online!](https://tio.run/##K0gtyjH9/18lXlvbuqAoM69ERb9CRVdHRalCJV7HH0RrqOhqa2sZaer4K5RnZOakqsTr6v7/b/ovv6AkMz@v@L9uHgA "Perl 5 – Try It Online")
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 17 bytes
```
r{n*íï- *'oï *+_x
```
[Try it online!](https://tio.run/##y00syUjPz0n7/7@oOk/r8NrD63UVtNTzD69X0NKOr/j/3/Q/AA "MathGolf – Try It Online")
## Explanation
```
r                   range(0, n)
 {                  start block or arbitrary length
  n                 newline char, or map array with newlines
   *                pop a, b : push(a*b)
    í               get total number of iterations of for loop
     ï              index of current loop, or length of last loop
      -             pop a, b : push(a-b)
                    space character
        *           pop a, b : push(a*b)
         '          push single character
          o         print TOS without popping
           ï        index of current loop, or length of last loop
                    space character
             *      pop a, b : push(a*b)
              +     pop a, b : push(a+b)
               _    duplicate TOS
                x   reverse int/array/string
```
[Answer]
# [J](http://jsoftware.com/), 29 bytes
```
[:|:@(,~|.)' O'#~1,.~i.+/\@,]
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/o61qrBw0dOpq9DTVFfzVlesMdfTqMvW09WMcdGL/a3KlJmfkK6QpGEIY6uowASN0AeP/AA "J – Try It Online")
Turned out very similar to Razetime's APL answer, though solved independently. I tried about 3 other approaches before realizing this one would be shortest.
[Answer]
# Stacked, ~~67~~ 63 bytes
```
args 0#1+:@x:>{!n x\-1-' '*'O'+n 2*' '*+'O'+x 1-n!=n*LF*+out}"!
```
Initial attempt, 67 bytes
```
args 0# :@v 1+2*:>[:v:+1+\-2/*' '*'O'+''split]"!fixshape tr rev out
```
Full program. Generates something like:
```
('O'
 ' ' 'O'
 ' ' 'O'
 'O')
```
Which is the padded, transposed, reversed, and outputted.
[Answer]
## Batch, 163 bytes
```
@set l=@for /l %%i in (1,1,%1)do @call
@set s=
%l% set s= %%s%%
@set t=
%l%:c&for /l %%j in (2,1,%%i)do @echo(
:c
@echo %s%O%t%O
@set s=%s:~1%
@set t=  %t%
```
[Answer]
## Ruby, 52 bytes
```
->x{(0..x).map{|a|$><<$/*a+' '*(x-a)+?O+' '*a*2+?O}}
```
No trailing newline (allowed by the rules: "*at most one trailing newline*")
]