[Question]
  [
For any positive integer \$k\$, let \$d(k)\$ denote the number of divisors of \$k\$. For example, \$d(6)\$ is \$4\$, because \$6\$ has \$4\$ divisors (namely \$1, 2, 3, 6\$).
Given a positive integer \$N\$, display a "skyline" in ASCII art using a fixed character, such that the height of the "building" located at horizontal position \$k\$ is \$d(k)\$ for \$k = 1, ..., N\$. See test cases below.
# Rules
* Any non-whitespace character may consistently be used, not necessarily `#` as shown in the test cases.
* The algorithm should theoretically work for arbitrarily high \$N\$. In practice, it is acceptable if the program is limited by time, memory, data-type size or screen size.
* Horizontally or vertically leading or trailing spaces or newlines are allowed.
* Input and output can be taken by any [reasonable means](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).
* [Programs or functions](http://meta.codegolf.stackexchange.com/a/2422/36398) are allowed, in any [programming language](http://meta.codegolf.stackexchange.com/a/2073/36398). [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* Shortest code in bytes wins.
# Test cases
`N = 10`:
```
     # # #
   # # ###
 #########
##########
```
`N = 50`:
```
                                               #  
                                   #           #  
                       #     #     #   # #     #  
                       #     #     #   # #     #  
           #     # #   #   # # #   #   # # ##  # #
           #   # # #   #   # # #   #   # # ##  # #
     # # # # ### # ### # ### # ##### ### # ### # #
   # # ### # ### # ### ##### # ##### ### # ### ###
 #################################################
##################################################
```
`N = 200`:
```
                                                                                                                                                                                   #                    
                                                                                                                                                                                   #                    
                                                                                                                       #                                               #           #                    
                                                                                                                       #                       #                       #           #                    
                                                                                                                       #                       #                       #           #           #        
                                                                                                                       #                       #                       #           #           #        
                                                           #           #           #     #     #           #           #     #     #       #   #     #     #   #       #           #           #     # #
                                                           #           #           #     #     #           #           #     #     #       #   #     #     #   #       #           #           #     # #
                                               #           #           #       #   #     #     #           #   #       #     #     #       #   #     #     #   # #     #       #   #           #     # #
                                   #           #           #           #       #   #     #     #   #       #   #       #     #     #       #   #     #     #   # #     #       #   #           #   # # #
                       #     #     #   # #     #     # #   #     #   # #     # #   #   # #     #   # # ##  # # # #     #     # # # #  ## # #   #     # # # #   # #  #  # #   # #   # # # #  ## #  ## # #
                       #     #     #   # #     #     # #   #   # #   # #     # #   #   # #     #   # # ##  # # # #     #     # # # #  ## # #   #     # # # #   # #  #  # #   # #   # # # #  ## #  ## # #
           #     # #   #   # # #   #   # # ##  # # # # #   #  ## # # # #  ## # #   #   # # #   # ### # ##  # # # # ##  #   # # # # #  ## # #   #  ## # ### #   # # ##  # ### ###   # # # # ### #  ## # #
           #   # # #   #   # # #   #   # # ##  # # # # #   #  ## # # # #  ## # ##  #   # # #   # ### # ##  # # # # ##  #   # # # # #  ## # #   #  ## # ### #   # # ##  # ### ###   # # # # ### #  ## # #
     # # # # ### # ### # ### # ##### ### # ### # ### ##### # ##### ### # ##### ### ##### ####### ### # ### # ### ####### ##### ### ##### # ######### # ##### ##### ### # ### ##### # ######### # ### # #
   # # ### # ### # ### ##### # ##### ### # ### ##### ##### # ##### ### # ##### ### ##### ####### ### # ### # ### ############# ### ##### # ######### # ##### ##### ### ##### ##### # ######### # ### # #
 #######################################################################################################################################################################################################
########################################################################################################################################################################################################
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
Uses `0` instead of `#`.
```
RÆD0ṁz⁶ṚY
```
[Try it online!](https://tio.run/nexus/jelly#@x90uM3F4OHOxqpHjdse7pwV@f//f1MDAA "Jelly – TIO Nexus")
[Answer]
# Octave, ~~41~~ ~~40~~ 32 bytes
Thanks to @StewieGriffin saved 8 bytes.
```
@(N)" #"(sort(~mod(k=1:N,k'))+1)
```
[Try it online!](https://tio.run/nexus/octave#@@@g4aeppKCspFGcX1SiUZebn6KRbWto5aeTra6pqW2o@T8xr1jD0EDzPwA "Octave – TIO Nexus")
Previous answers:
```
@(N)" #"(sort(~bsxfun(@mod,k=1:N,k')+1))
```
[Try it online!](https://tio.run/nexus/octave#@@@g4aeprqCsrlGcX1SiUZdUXJFWmqfhkJufopNta2jlp5OtrqltqKn5PzGvWMPQQPM/AA "Octave – TIO Nexus")
```
@(N)" #"(sort(ismember((k=1:N)./k',k))+1)
```
[Try it online!](https://tio.run/nexus/octave#@@@g4aeprqCsrlGcX1SikVmcm5qblFqkoZFta2jlp6mnn62uk62pqW2o@T8xr1jD0EDzPwA "Octave – TIO Nexus")
Explanation:
```
N=5;
d = (1:N)./(1:N)'    %divide each of numbers from 1 to N by 1 to N 
                     %a [N by N] matrix created
d =
   1.00   2.00   3.00   4.00   5.00
   0.50   1.00   1.50   2.00   2.50
   0.33   0.66   1.00   1.33   1.66
   0.25   0.50   0.75   1.00   1.25
   0.20   0.40   0.60   0.80   1.00
m = ismember(d,1:N)      %find divisors of each number
m =
  1  1  1  1  1
  0  1  0  1  0
  0  0  1  0  0
  0  0  0  1  0
  0  0  0  0  1
idx = sort(m)                  %sort the matrix
idx =
  0  0  0  0  0
  0  0  0  0  0
  0  0  0  1  0
  0  1  1  1  1
  1  1  1  1  1
" #"(idx+1)     %replace 0 and 1 with ' ' and '#' respectively
                                                                                                          
   #
 ####
#####
```
[Answer]
## C, ~~99~~ ~~95~~ ~~92~~ ~~91~~ 90 bytes
```
c,l,i,j;f(n){for(j=n;j--;puts(""))for(i=0;i<n;c=!putchar(32|c>j))for(l=++i;l;c+=i%l--<1);}
```
See it [work here](https://tio.run/nexus/c-gcc#JclBCsIwEEDRtT1FLAgTkkCruJrGu4TR0AkxKbW6qT2262hw9eH9Qjpq1gE9JLn6PEOwCYMxOD2XB7StlBXZdshDQrL7n9PoZjgd33QJ/x2tUowRSVk@RGOGXuJWOC3i7jiBeGW@Ctmszc5D30msPddu5ZOyIUfj7Qs).
[Answer]
# [Haskell](https://www.haskell.org/), 71 bytes
`f` takes an `Int` and returns a `String`.
```
f m|l<-[1..m]=unlines[[last$' ':drop(m-i)['#'|0<-mod n<$>l]|n<-l]|i<-l]
```
[Try it online!](https://tio.run/nexus/haskell#FcRBCsMgEADArwgVTA6KKfRS1n5EcpBqYMFdi1p68e82mcNQQHbIPdXw7nI5TE0hOoDV/EqNbR6CRgbtN2Nod1/OyKl5n0PrUgn1jLV8FtK4enVTw4KmEgWDfOV9MOhzvJ5zs@Jhxd3aPw "Haskell – TIO Nexus")
* `m` is the `N` of the OP (Haskell variables must be lowercase.)
* The abbreviation `l=[1..m]` is used in the nested list comprehensions for iterating through all of rows, columns, and potential divisors. This means some extra initial rows filled with whitespace.
* `n` is column (also number checked), `i` is row.
* `['#'|0<-mod n<$>l]` is a list of `'#'` characters with length the number of divisors of `n`.
[Answer]
# [Python 3](https://docs.python.org/3/), 111 bytes
```
lambda n:'\n'.join([*map(''.join,zip(*['#'*sum(x%-~i==0for i in range(x))+n*' 'for x in range(1,n+1)]))][::-1])
```
[Try it online!](https://tio.run/nexus/python3#RcjBCgIhEADQXxEiZsbdjfUUCH6J68EoYyJnxS2QDv26ER06vpfc0u8xn85RiYVF4HBbWdDrHAvCT@OLC2oPO9DbM2PbT292bk5rVaxYVI1yvWAjGkSDgu@3/5tRBkOBKHhrJxOol8rywITHmah/AA "Python 3 – TIO Nexus")
---
This produces some leading vertical whitespace
[Answer]
# Octave, 61 bytes
```
for i=1:input(''),p(1:nnz(~rem(i,1:i)),i)=35;end,[flip(p),'']
```
**Explanation:**
```
for i=1:input('')         % Loop, for i from 1 to the input value
 p(1:nnz(~rem(i,1:i)),i)=35;end,[flip(p),'']   
% Breakdown:
         ~rem(i,1:i)      % Return true if the remainder of i divided by any of the values
                          % in the vector 1 - i
     nnz(~rem(i,1:i))     % Check how many of them are non-zero
 p(1:nnz(~rem(i,1:i)),i)=35;end   % Assign the value 35 (ASCII for #) to rows 1
                                  % to the number of divisors of i, in column i
end,              % End loop
[flip(p),'']      % Flip the matrix, and concatenate it with the empty string
```
---
A few things I wish to highlight
* Takes the input directly into the loop
	+ Doesn't assign the input value to any variable
* Doesn't initialize any array
	+ It creates it on the fly, adding columns and rows as necessary
* Automatically casts ASCII-value 0 to whitespace (ASCII-32)
---
What happens inside the loop (suppose input `6`)
```
p =  35
p =
   35   35
    0   35
p =
   35   35   35
    0   35   35
p =
   35   35   35   35
    0   35   35   35
    0    0    0   35
p =
   35   35   35   35   35
    0   35   35   35   35
    0    0    0   35    0
p =
   35   35   35   35   35   35
    0   35   35   35   35   35
    0    0    0   35    0   35
    0    0    0    0    0   35
```
1. Starts of as a single 35
2. Expands one column and one row, to make room for the two divisors of 2
3. Expands one column, to make room for 3 (only two divisors)
4. Expands one column and one row, to make room for the 3 divisors (`1,2,4`)
5. Expands one column, to make room for 5
6. Expands one column and one row, to make room for the 4 divisors (`1,2,3,6`)
Finally we flip it, and converts it to a string, implicitly changing the `0` to `32`:
```
warning: implicit conversion from numeric to char
ans =
     #
   # #
 #####
######
```
[Answer]
## Mathematica, ~~59~~ 57 bytes
```
Rotate[Grid@Map[X~Table~#&,0~DivisorSigma~Range@#],Pi/2]&
```
[![enter image description here](https://i.stack.imgur.com/nOnj2.png)](https://i.stack.imgur.com/nOnj2.png)
[Answer]
# C#, 333 281 Bytes
```
using System.Linq;using C=System.Console;class P{static void Main(){var n=int.Parse(C.ReadLine());var v=new int[n];for(var k=2;k<=n;k++)for(var i=1;i<k;i++)if(k%i==0)v[k-1]++;for(var i=0;i<v.Length;i++)for(var u=v.Max()-v[i];u<v.Max();u++){C.SetCursorPosition(i,u);C.Write("#");}}}
```
With line breaks:
```
using System.Linq;
using C = System.Console;
class P
{
    static void Main()
    {
        var n = int.Parse(C.ReadLine());
        var v = new int[n];
        for (var k = 2; k <= n; k++)
            for (var i = 1; i < k; i++)
                if (k % i == 0)
                    v[k - 1]++;
        for (var i = 0; i < v.Length; i++)
            for (var u = v.Max() - v[i]; u < v.Max(); u++)
            {
                C.SetCursorPosition(i, u);
                C.Write("#");
            }
    }
}
```
While I'm sure this is possible shorter as well, I hope we'll achieve a shorter solution together ;)
*Saved 52 Bytes with the help of raznagul*
[Answer]
## Mathematica, 99 bytes
```
{T=DivisorSigma[0,Range@#];Row[Column/@Table[Join[Table[,Max[T]-T[[i]]],$~Table~T[[i]]],{i,1,#}]]}&
```
for N=50
[![enter image description here](https://i.stack.imgur.com/IAd8z.jpg)](https://i.stack.imgur.com/IAd8z.jpg)
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 19 bytes
```
⊖⍉↑'#'⍴¨⍨+⌿0=∘.|⍨⍳⎕
```
[Try it online!](https://tio.run/nexus/apl-dyalog#e9TR7pJZllmcXxScXZmTmZf6/1HXtEe9nY/aJqorqz/q3XJoxaPeFdqPevYb2D7qmKFXA@Q96t38qG/q/0cd7f9R9XIZGnChiZhiiBgZGAAA "APL (Dyalog Unicode) – TIO Nexus")
`⎕` get evaluated input (*N*)
`⍳` 1...*N*
`∘.|⍨` division remainder table with 1...*N* both as vertical and as horizontal axis
`0=` where equal to zero (i.e. it divides)
`+⌿` sum the columns (i.e. gives count of divisors for each number)
`'#'⍴¨⍨` use each number to reshape the hash character (gives list of strings)
`↑` mix (list of strings into table of rows)
`⍉` transpose
`⊖` flip upside down
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~23~~ ~~22~~ 20 bytes
```
Ｆ…·¹Ｎ«Ｊι⁰Ｆι¿¬﹪ι⁺κ¹↑#
```
[Try it online!](https://tio.run/##RYxBCsIwFET3nuJTNz@QQrtwoyeo0FJEDxBjqsE0CWnSjXj2b5qNbzUMM0@@RJBOGKLJBcDOSpMWvaqLsE@FLYfO@hSHNN9VQMYYfHaQOafZXx1qDg07labcNSt5Q0@Ag4vYu0cyZTlmM745tFnz322MQduIx5vnUO2rLPwSHRqqV6oX8wM "Charcoal – Try It Online") Link is to verbose version of code. Edit: Saved 1 byte by looping `k` from `0` to `i-1` and adding `1` inside the loop. Saved a further two bytes by not storing the input in a variable. Explanation:
```
Ｆ…·¹Ｎ       for (i : InclusiveRange(1, InputNumber()))
«           {
 Ｊι⁰         JumpTo(i, 0);
 Ｆι          for (k : Range(i))
  ¿¬﹪ι⁺κ¹     if (!(i % (k + 1)))
   ↑#          Print(:Up, "#");
            }
```
Edit: This 18-byte "one-liner" (link is to verbose version of code) wouldn't have worked with the version of Charcoal at the time the question was submitted: [Try it online!](https://tio.run/##HYtBCsIwEAC/EuplF7agBy/6ggotRewDYgwaWDchbSq@fm28DcOMe9nsomXVMQdZ4DQlMr1N0InjMofVX608PRzIdJLKMpT33WdAJHOJQaCmgczNZ7H5C318FI7VjNtdL67ph0yza/6EiGfV417bVduZfw "Charcoal – Try It Online")
```
↑Ｅ…·¹Ｎ⪫Ｅι⎇﹪ι⁺¹λω#ω
```
[Answer]
# [Python 2](https://docs.python.org/2/), 101 bytes
```
N=input();r=range
for i in r(N,0,-1):print''.join('# '[i>sum(x%-~p<1for p in r(x))]for x in r(1,1+N))
```
[Try it online!](https://tio.run/nexus/python2#@@9nm5lXUFqioWldZFuUmJeeypWWX6SQqZCZp1Ck4adjoKNrqGlVUJSZV6KurpeVn5mnoa6soB6daVdcmqtRoapbV2BjCNJRANFRoakZC@JWQLiGOobafpqa//8bGgAA "Python 2 – TIO Nexus")
This produces (a lot of) vertically leading whitespace. It prints a total of `N` lines, the great majority of which will [typically](https://en.wikipedia.org/wiki/Divisor_function#Growth_rate) be blank.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~34 33 16~~ 14 bytes
*Saved 17 bytes thanks to @ETHproductions*
```
õ@'#pXâ lÃ·z w
```
[Try it online!](https://tio.run/nexus/japt#@394q4O6ckHE4UUKOYebD22vUij//9/QAAA "Japt – TIO Nexus")
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGLOnline), 8 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
∫Λ⁄╗*}⁰H
```
[Try it here!](https://dzaima.github.io/SOGLOnline/?code=JXUyMjJCJXUwMzlCJXUyMDQ0JXUyNTU3KiU3RCV1MjA3MEg_,inputs=NTA_,v=0.12)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 12 bytes
Code:
```
LÑ€g'#×.BøR»
```
Explanation:
```
L             # Create the range 1 .. input
 Ñ            # Get the list of divisors of each
  €g          # Get the length of each element
    '#        # Push a hash tag character
      ×       # String multiply
       .B     # Squarify, make them all of equal length by adding spaces
         ø    # Transpose
          R   # Reverse the array
           »  # Join by newlines
```
Uses the **05AB1E** encoding. [Try it online!](https://tio.run/nexus/05ab1e#@@9zeOKjpjXp6sqHp@s5Hd4RdGj3//@mBgA "05AB1E – TIO Nexus")
[Answer]
# R, ~~83~~ 82 bytes
*-1 byte thanks to MickyT*
```
N=scan();m=matrix('#',N,N);for(i in 1:N)m[i,1:sum(i%%1:N>0)]=' ';write(m,'',N,,'')
```
Reads `N` from stdin.
```
N=scan()                        # read N
m=matrix('#',N,N)               # make an NxN matrix of '#' characters
for(i in 1:N)                   # for each integer in the range
    m[i,1:sum(i%%1:N!=0)]=' '   # set the first n-d(n) columns of row i to ' '
write(m,'',N,,'')               # print to console with appropriate formatting
```
[Try it online!](https://tio.run/##K/r/38@2ODkxT0PTOtc2N7GkKLNCQ11ZXcdPx0/TOi2/SCNTITNPwdDKTzM3OlPH0Kq4NFcjU1UVKGBnoBlrq66gbl1elFmSqpGrow7SBSQ1/5sa/AcA)
[Answer]
# PowerShell, 101 bytes
```
((($d=1.."$args"|%{($x=$_)-(1..$_|?{$x%$_}).Count})|sort)[-1])..1|%{$l=$_;-join($d|%{' #'[$_-ge$l]})}
```
Less golfed test script:
```
$f = {
$d=1.."$args"|%{
    ($x=$_)-(1..$_|?{$x%$_}).Count
}                                     # $d is the Divisor count array
$maxHeight=($d|sort)[-1]
$maxHeight..1|%{
    $l=$_
    -join($d|%{' #'[$_-ge$l]})
}
}
@(
    ,(10, 
    "     # # #",
    "   # # ###",
    " #########",
    "##########")
    ,(50, 
    "                                               #  ",
    "                                   #           #  ",
    "                       #     #     #   # #     #  ",
    "                       #     #     #   # #     #  ",
    "           #     # #   #   # # #   #   # # ##  # #",
    "           #   # # #   #   # # #   #   # # ##  # #",
    "     # # # # ### # ### # ### # ##### ### # ### # #",
    "   # # ### # ### # ### ##### # ##### ### # ### ###",
    " #################################################",
    "##################################################")
    ,(200,
    "                                                                                                                                                                                   #                    ",
    "                                                                                                                                                                                   #                    ",
    "                                                                                                                       #                                               #           #                    ",
    "                                                                                                                       #                       #                       #           #                    ",
    "                                                                                                                       #                       #                       #           #           #        ",
    "                                                                                                                       #                       #                       #           #           #        ",
    "                                                           #           #           #     #     #           #           #     #     #       #   #     #     #   #       #           #           #     # #",
    "                                                           #           #           #     #     #           #           #     #     #       #   #     #     #   #       #           #           #     # #",
    "                                               #           #           #       #   #     #     #           #   #       #     #     #       #   #     #     #   # #     #       #   #           #     # #",
    "                                   #           #           #           #       #   #     #     #   #       #   #       #     #     #       #   #     #     #   # #     #       #   #           #   # # #",
    "                       #     #     #   # #     #     # #   #     #   # #     # #   #   # #     #   # # ##  # # # #     #     # # # #  ## # #   #     # # # #   # #  #  # #   # #   # # # #  ## #  ## # #",
    "                       #     #     #   # #     #     # #   #   # #   # #     # #   #   # #     #   # # ##  # # # #     #     # # # #  ## # #   #     # # # #   # #  #  # #   # #   # # # #  ## #  ## # #",
    "           #     # #   #   # # #   #   # # ##  # # # # #   #  ## # # # #  ## # #   #   # # #   # ### # ##  # # # # ##  #   # # # # #  ## # #   #  ## # ### #   # # ##  # ### ###   # # # # ### #  ## # #",
    "           #   # # #   #   # # #   #   # # ##  # # # # #   #  ## # # # #  ## # ##  #   # # #   # ### # ##  # # # # ##  #   # # # # #  ## # #   #  ## # ### #   # # ##  # ### ###   # # # # ### #  ## # #",
    "     # # # # ### # ### # ### # ##### ### # ### # ### ##### # ##### ### # ##### ### ##### ####### ### # ### # ### ####### ##### ### ##### # ######### # ##### ##### ### # ### ##### # ######### # ### # #",
    "   # # ### # ### # ### ##### # ##### ### # ### ##### ##### # ##### ### # ##### ### ##### ####### ### # ### # ### ############# ### ##### # ######### # ##### ##### ### ##### ##### # ######### # ### # #",
    " #######################################################################################################################################################################################################",
    "########################################################################################################################################################################################################")
) | % {
    $n,$expected = $_
    $result = &$f $n
    "$result"-eq"$expected"
    #$result    # uncomment this to enjoy the view of the Divisor skyline
}
```
Output:
```
True
True
True
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~13~~ 11 bytes
```
↔T' †K'#mḊḣ
```
[Try it online!](https://tio.run/##yygtzv7//1HblBB1hUcNC7zVlXMf7uh6uGPx////TQ0A "Husk – Try It Online")
-2 bytes from Ko King(No, not JoKing).
[Answer]
## [J](http://jsoftware.com/), 28 bytes
```
[:|:&.|.[('#',@$~1+_&q:)@-i.
```
Defines a monadic verb.
[Try it online!](https://tio.run/nexus/j#@5@mYGulEG1VY6WmV6MXraGurK7joFJnqB2vVmil6aCbqfc/NTkjXyFNwdTgPwA "J – TIO Nexus")
## Explanation
```
[:|:&.|.[('#',@$~1+_&q:)@-i.  Input is y.
                          i.  Range from 0 to y-1
        [                -    subtracted from y (gives range from y to 1).
         (             )@     For each of the numbers:
                   _&q:         Compute exponents in prime decomposition,
                 1+             add 1 to each,
          '#'  $~               make char matrix of #s with those dimensions,
             ,@                 and flatten into a string.
                              The resulting 2D char matrix is padded with spaces.
[:|:&.|.                      Reverse, transpose, reverse again.
```
[Answer]
# PHP, 126 Bytes
```
for(;$n++<$argn;)for($c=$d=0;$d++<$n;)$n%$d?:$r[$n]=++$c;for($h=max($r);$h--;print"
")for($n=0;$n++<$argn;)echo$h<$r[$n]?:" ";
```
[Try it online!](https://tio.run/nexus/php#TcyxCsIwFEbhvU9Rwi@0hIIODvbmkgcpDiVRr4O3IXTw7WPTLq4fh@N8ktQ2mPNL@XK9UXkuuSOotW5H6isgMCKfCbH6htAToh@RJ@idrUWgvRP@zN8OuSfIMFDKb11NY46J1sPf@RFkgbhj4kfTGirlBw "PHP – TIO Nexus")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 34 bytes
```
⟦fᵐlᵐgDh⌉⟦↔gᵐ;D↔z{z{>₁∧0ṫ|∧Ṣ}ᵐcẉ}ᵐ
```
[Try it online!](https://tio.run/nexus/brachylog2#@/9o/rK0h1sn5ABxukvGo55OoMCjtinpQL61C5BRVV1VbfeoqfFRx3KDhztX1wDphzsX1QKlkx/u6gTR//@bGgAA "Brachylog – TIO Nexus")
[Answer]
## [Alice](https://github.com/m-ender/alice), 33 bytes
```
I.!.t&w?t!aot&wh.Bdt.?-ex' +o&;k@
```
[Try it online!](https://tio.run/nexus/alice#@@@pp6hXolZuX6KYmA@kM/ScUkr07HVTK9QVtPPVrLMd/v9XAQA "Alice – TIO Nexus")
Input is (unfortunately) [in the form of a code point](https://codegolf.meta.stackexchange.com/q/4708/8478). At least it reads a UTF-8 character, so you can use larger inputs than 255, but they're still limited and it's a pretty painful input format. For three additional bytes, we can read a decimal integer:
```
/
ki@/.!.t&w?t!aot&wh.Bdt.?-ex' +o&;
```
[Try it online!](https://tio.run/nexus/alice#@6/PlZ3poK@nqFeiVm5fopiYD6Qz9JxSSvTsdVMr1BW089Ws//83NAAA "Alice – TIO Nexus")
The non-whitespace character in the output is `!`.
Note that the solution also prints a ton of leading whitespace (it always starts with an empty line and then prints an `NxN` grid so for larger `N`, there will be many lines of spaces before the first `!`s.)
### Explanation
I've used and explained the `&w...k` construction before (for example [here](https://codegolf.stackexchange.com/a/116972/8478)). It's a neat little idiom that pops an integer **n** and then runs a piece of code **n+1** times (consequently, it's usually used as `t&w...k` to run a loop **n** times, with `t` decrementing the input value). This is done by working with the *return address stack* (RAS). `w` pushes the current IP address to the RAS, and if we repeat it with `&` then the address gets pushed **n** times. `k` pops one address from the RAS and jumps back there. If the RAS is empty, it does nothing at all and the loop is exited.
You might notice that it's not trivially possible to nest these loops, because at the end of the inner loop, the stack isn't empty, so the `k` doesn't become a no-op. Instead, the IP would jump back to the beginning of the outer loop. The general way to fix this involves wrapping the inner loop in its own subroutine. But if we can arrange the nested loop such that the outer loop *ends* with the inner loop, we can actually make use of this behaviour and even save on one `k`!
So this construction:
```
&wX&wYk
```
Is a working nested loop which runs the `XYYYXYYYXYYY...` (for some number of `Y`s in each iteration). It's pretty neat that we can end both loops with a single `k`, because it will consume an outer address from RAS each time the inner addresses have been depleted.
This idiom is used in the program to run the loop over the output grid.
```
I         Read a character and push its code point as input N.
.!        Store a copy on the tape.
.         Make another copy.
t&w       Run this outer loop N times. This loops over the lines of the
          output, so the current iteration corresponds to a divisor count
          no more than i (i counting down from N).
  ?t!       Decrement the value on the tape. That means we'll actually have
            i-1 on the tape during the iteration.
  ao        Print a linefeed. Doing this now leads to the weird leading linefeed, 
            but it's necessary for the &w...&w...k pattern.
  t&w       Remember that we still have a copy of N on the stack. We'll also
            ensure that this is the case after each loop iteration. So this
            also runs the inner loop N times. This iterates over the columns
            of the output grid so it's j that goes from 1 to N and corresponds
            to the number whose divisors we want to visualise.
              At this point the stack will always be empty. However, operating
              on an empty stack works with implicit zeros at the bottom of
              the stack. We'll use the top zero to keep track of j.
    h         Increment j.
    .B        Duplicate j and push all of its divisors.
    dt        Push the stack depth minus 1, i.e. the divisor count of j.
    .         Duplicate the divisor count.
    ?-        Retrieve i-1 from the tape and subtract it. So we're computing
              d(j)-i+1. We want to output a non-whitespace character iff this
              value is positive (i.e. if i is no greater than d(j)).
    ex        Extract the most significant bit of this value. This is 1 for
              all positive values and 0 for non-positive ones. It's the shortest
              way (I believe) to determine if a value is positive.
    ' +       Add this to the code point of a space. This gives a 33, or '!',
              if the cell is part of the skyline.
    o         Output the character.
    &;        We still have all the divisors and the divisor count on the stack.
              We pop the divisor count to discard that many values (i.e. to
              get rid of the divisors again).
k         Return to the appropriate loop beginning to run the continue the
          nested loop.
@         Terminate the program.
```
[Answer]
# [Actually](https://github.com/Mego/Seriously), 25 bytes
```
R♂÷♂l;M' *╗⌠'#*╜@+⌡M┬♂ΣRi
```
[Try it online!](https://tio.run/nexus/actually#@x/0aGbT4e1AIsfaV11B69HU6Y96FqgrAxlzHLQf9Sz0fTRlDVD23OKgzP//DQ0MAA)
## 22-byte version with a lot of leading newlines
```
;╗R⌠÷l'#*╜' *@+⌡M┬♂ΣRi
```
[Try it online!](https://tio.run/nexus/actually#ASoA1f//O@KVl1LijKDDt2wnIyrilZwnICpAK@KMoU3ilKzimYLOo1Jp//8xMDA)
[Answer]
# SpecBAS - 149 bytes
```
1 INPUT n: DIM h(n)
2 FOR i=1 TO n
3 FOR j=1 TO i
4 h(i)+=(i MOD j=0)
5 NEXT j
6 NEXT i
7 FOR i=1 TO n
8 FOR j=51-h(i) TO 50
9  ?AT j,i;"#"
10 NEXT j
11 NEXT i
```
An array keeps track of number of divisors, then prints the right number of characters down to screen position 50.
[![enter image description here](https://i.stack.imgur.com/sNuLc.png)](https://i.stack.imgur.com/sNuLc.png)
[Answer]
# PHP, 99 bytes
```
for(;$d<$k?:$k++<$argn+$d=$n=0;)$k%++$d?:$r[--$n]=str_pad($r[$n],$k).H;ksort($r);echo join("
",$r);
```
prints one leading space; run as pipe with `php -nr '<code>'` or [try it online](http://sandbox.onlinephpfunctions.com/code/a112e085d13e69ea94bdfc3a545d6fff9a6f2d81).
**breakdown**
```
for(;$d<$k?:                    # inner: loop $d from 1 to $k
    $k++<$argn+$d=$n=0;)        # outer: loop $k from 1 to $argn, reset $d and $n
    $k%++$d?:                       # if $d divides $k
        $r[--$n]=str_pad($r[$n],$k).H;  # add one store to building $k
ksort($r);echo join("\n",$r);   # reverse and print resulting array
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~46~~ 44 bytes
```
Grid[PadLeft[0Divisors@Range@#-" "]+" "]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78r/HfvSgzJTogMcUnNa0k2sAlsyyzOL@o2CEoMS891UFZV0lBKfZ9f7s2iFb776BgbKr5/79uQVFmXgkA "Wolfram Language (Mathematica) – Try It Online") But maybe [try it online! with ColumnForm instead of Grid](https://tio.run/##y00syUjNTSzJTE78r/HfOT@nNDfPLb8oNzogMcUnNa0k2sAlsyyzOL@o2CEoMS891UFZV0lBKfZ9f7s2iFb776BgbKr5/79uQVFmXgkA "Wolfram Language (Mathematica) – Try It Online"), since `Grid` doesn't work in TIO. In Mathematica, it looks better:
[![Mathematica output](https://i.stack.imgur.com/HE7hY.png)](https://i.stack.imgur.com/HE7hY.png)
A third Mathematica solution... `Divisors@Range@#` finds all the divisors in the range we want, and then we multiply by `0` and subtract `" "`, making every divisor equal to `-" "`.
`PadLeft` adds zeroes on the left, creating a sideways skyline, whose orientation we fix with ``=`\[Transpose]`. Finally, adding `" "` to everything makes all entries either `0` or `" "`.
As an alternative, the 59-byte `""<>Riffle[PadLeft["X"-" "+0Divisors@Range@#]+" ","\n"]&` produces string output.
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 58 bytes
```
D,g,@,FL1+
D,k,@~,J
L,R€gd"#"€*$dbM€_32C€*z£+bUBcB]bR€kbUn
```
[Try it online!](https://tio.run/##S0xJKSj4/99FJ13HQcfNx1Cby0UnW8ehTseLy0cn6FHTmvQUJWUlIK2lkpLkC6TjjY2cQdyqQ4u1k0Kdkp1ik0DKspNC8/7nWRkacHGp5CTmJqUkKhjaAXn@XB55yEKmmEKGBkCx//9NDQA "Add++ – Try It Online")
## How it works
Our program consists of two helpers functions, `g` and `k`, and the main lambda function. `g` iterates over each integer, \$x\$, between \$1\$ and \$n\$ and returns \$d(x)\$ as defined in the challenge body, while `k` takes a list of characters and concatenates them into a single string.
The main lambda function generates \$A = [d(1), d(2), d(3), ..., d(n)]\$, then repeats the `#` character for each element of \$A\$. We then take \$\max(A)\$, and subtract each element in \$A\$ from this maximum, before yielding this number of spaces for each element and concatenating the spaces to the repeated hashes. Next, we transpose and reverse the rows, before joining each line on newlines. Finally, we output the skyline.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
LÑ_ζRJ»
```
Uses `0` (or `1`) instead of `#`.
[Try it online.](https://tio.run/##yy9OTMpM/f/f5/DE@HPbgrwO7f7/39QAAA)
**Explanation:**
```
L        # Push a list in the range [1, (implicit) input]
 Ñ       # Convert each value to a list of its divisors
  _      # Convert each inner integer to 0
   ζ     # Zip/transpose; swapping rows/columns, with space as default filler
    R    # Reverse the list of lists
     J   # Join each inner list together
      »  # And then join the list of strings by newlines
         # (after which the result is output implicitly)
```
The `_` (==0) has some a few alternatives to get distinct values: `a` (is\_alphabetic); `Ā` (!=0); `d` (>=0):  
[try it online](https://tio.run/##yy9OTMpM/f9fySk1Lb8o1UpByd7n8ERbLiXHtJLUIoWE@ASQkEu8DlwkESKSiBA50gAROtKAEEsBC6Xo/P9vaAAA).
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), `L`, ~~6~~ 5 bytes
```
ƛKL×*
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=L&code=%C6%9BKL%5C%23*&inputs=10&header=&footer=)
## Explained
```
ƛKL×*
ƛ       # Over the range [1, input] do the following:
 KL     #   Push the length of the list of that number's divisors
   ×    #   Push '*'
    *   #   And multiply the two together, repeating the "*"
        # Automatically close the map and then use the L flag to vertically join that list
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 16 bytes
```
j_.tm*\#/%LdSQ0S
```
[Try it online!](http://pyth.herokuapp.com/?code=j_.tm%2a%5C%23%2F%25LdSQ0S&input=50&debug=0)
]