175
\$\begingroup\$

In this challenge, users will take turns completeing three fairly simple coding tasks in programming languages that are allowed to be progressively older.

The first answer must use a programming language that was made in the year 2015. Once there is at least one answer from a 2015 language, answers may use programming languages that were made in 2014. Similarly, answers that use languages from 2013 are not allowed until there is at least one 2014 answer.

In general, the use of a programming language from the year Y is not allowed until an answer using a language from the year Y+1 has been submitted. The only exception is Y = 2015.

Finding Your Language's Year

To answer this question, you must know the year your programming language was "made in". This is, of course, a subjective term; some languages were developed over the course of multiple years, and many languages are still being upgraded every year. Let the year a language was "made in" be the first year an implementation for that language appeared in the general public.

For example, Python was "made in" 1991, though its development had been in progress since 1989, and version 1.0 wasn't released until 1994.

If this year is still subjective, just use your common sense to choose the most appropriate year. Don't get bogged down in slight disagreements about year choices. Please provide a link to a source that says when your language was made.

Different versions or standards of a programming language (e.g. Python 1, 2, 3) are counted as the same language with the same initial year.

So, unless your language's year is 2015, you can only submit your answer once an answer has been submitted whose language's year is the year just before yours.

If a valid answer with the same year as yours already exists, then you may answer. It doesn't matter if your language was developed earlier or later in the year.

Tasks

You must complete Tasks 1 through 3. Task 0 is optional.

These tasks were more or less chosen to correspond to three important aspects of programming: providing output (Task 1), looping (Task 2), and recursion (Task 3).

Task 0 - Language History (optional)

Write at least a paragraph explaining the history of your chosen programming language: who developed it, why, how, etc. This is especially encouraged if you personally were around when the language came into being, and maybe even played a part in its development. Feel free to relate personal anecdotes about the effect the language had on you or your job, or anything like that.

If you're too young to know much about the history of your language without a lot of research, consider leaving a note to older users that says they can edit your post and add in some first-hand history.

Task 1 - "Hello, World!" Variant

Write a program that prints

[language name] was made in [year made]!

to your language's standard output area (stdout for most recent languages).

For example, if the language was Python, the output would be:

Python was made in 1991!

Task 2 - ASCII Art N

Write a program that lets the user enter in an odd positive integer (you may assume the input is always valid), and prints out an ASCII art letter N made using the character N.

If the input is 1, the output is:

N

If the input is 3, the output is:

N N
NNN
N N

If the input is 5, the output is:

N   N
NN  N
N N N
N  NN
N   N

If the input is 7, the output is:

N     N
NN    N
N N   N
N  N  N
N   N N
N    NN
N     N

The pattern continues on like this. The output may contain trailing spaces.

Task 3 - GCD

Write a program that lets the user enter in two positive integers (you may assume the input is always valid), and prints their greatest common divisor. This is defined as the largest positive integer that divides both numbers without leaving a remainder. It can be readily calculated using the Euclidean algorithm.

Examples:

8, 124
12, 84
3, 303
5689, 21
234, 8766

You may use a built in function but try finding out if it was there in the first version of your language. If not, try not using it.

Rules

  • You may answer multiple times, but each new answer must use a language made at least 5 years before the language in your last answer. So if you answered with a 2015 language, you couldn't answer again until 2010 languages are allowed. If you start with a 2010 answer, you can't make a 2015 answer your second answer because 2015 is not before 2010.
  • If possible, write your code so that it would have worked in the very first version of your language (or as old a version as possible). (This is not a requirement because finding old compilers/interpreters for some languages may be difficult.)
  • Refrain from posting a language that has already been posted unless the posted answer has significant errors or you have a very different way of completing the tasks.
  • Golfing your code is fine but not required.
  • A trailing newline in the output of any program is fine.
  • For tasks 2 and 3, all input values below some reasonable maximum like 216 should work (256 at the very least).
  • Your language must have existed before this question was posted.
  • Very old programming languages may have different forms of input and output than what we think of today. This is fine. Complete the tasks to the best of your ability in the context of your language.

Scoring

Your submission's score is:

upvotes - downvotes + (2015 - languageYear) / 2 

Thus, 0.5 is added to the vote count for every year before 2015, giving the advantage to older languages. The submission with the highest score wins.

Answer List

The Stack Snippet below lists all the valid answers according to their language year.

You must start your post with this Markdown line to ensure it is listed correctly:

#[year] - [language name]

For example:

#1991 - Python

The language name may be in a link (it will be the same link in the answer list):

#1991 - [Python](https://www.python.org/)

Answers that don't follow this format, or have a year that is not allowed yet, or come from a user that already answered in the last 5 years are marked as invalid.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script>$(function(){function e(e,r){var a="https://api.stackexchange.com/2.2/questions/48476/answers?page="+e.toString()+"&pagesize=100&order=asc&sort=creation&site=codegolf&filter=!YOKGPOBC5Yad160RQxGLP0r4rL";$.get(a,r)}function r(e){if(e.items.forEach(function(e){var r=e.link,a=e.owner.display_name,i=e.body.match(/<h1\b[^>]*>(\d{4}) - (.*?)<\/h1>/);if(i&&i.length>=3)var h=parseInt(i[1]),u=i[2];h&&u&&n>=h&&h>=t&&(!d.hasOwnProperty(e.owner.user_id)||d[e.owner.user_id]-h>=p)?(d[e.owner.user_id]=h,h==t&&--t,o.hasOwnProperty(h)||(o[h]=[]),o[h].push({language:u,user:a,link:r,score:e.score+(n-h)/2})):s.push(' <a href="'+r+'">'+a+"</a>")}),e.has_more)runQuery(++a,r);else{for(var i=n,h=[];o.hasOwnProperty(i);){for(var u=$("<tr>").append($("<td>").text(i.toString())),l=$("<td>"),c=$("<td>"),g=$("<td>"),f=0;f<o[i].length;f++){var v=o[i][f];l.append(v.language),c.append($("<a>").html(v.user).attr("href",v.link)),g.append(v.score),f+1<o[i].length&&(l.append("<br><br>"),c.append("<br><br>"),g.append("<br><br>"))}u.append(l).append(c).append(g),h.push(u),--i}$("#answers").find("tbody").append(h),s.length>0?$("#invalid").append(s):$("#invalid").remove()}}var a=1,n=2015,t=n-1,p=5,o={},s=[],d={};e(1,r)})</script><style>html *{font-family: Helvetica, Arial, sans-serif;}table{border: 4px solid #a4a; border-collapse: collapse;}th{background-color: #a4a; color: white; padding: 8px;}td{border: 1px solid #a4a; padding: 8px;}div{font-size: 75%;}</style><table id='answers'> <tr> <th>Year</th> <th>Language</th> <th>User (answer link)</th> <th>Score</th> </tr></table><div id='invalid'><br>Invalid Answers:</div>

\$\endgroup\$
16
  • 2
    \$\begingroup\$ This should help. \$\endgroup\$
    – swish
    Apr 6, 2015 at 9:10
  • 27
    \$\begingroup\$ Wikipedia has a list for everything: this one for non-esoteric languages by year. \$\endgroup\$
    – Sanchises
    Apr 6, 2015 at 12:30
  • 2
    \$\begingroup\$ Should Task 3 actually use recursion or is it enough that it produces the correct result? If I need to write my own GCD function I usually just use a loop but I wrote a recursive one specially for this challenge. There are many submitted answers that just use a loop. \$\endgroup\$
    – CJ Dennis
    May 3, 2015 at 2:51
  • 5
    \$\begingroup\$ I feel like making a second account just to get us past 1971. \$\endgroup\$
    – marinus
    May 5, 2015 at 10:49
  • 6
    \$\begingroup\$ If we can get it back to 1952, I have someone spinning up a historic machine that could do 1951 (Pegasus) solutions and test them! \$\endgroup\$ May 19, 2015 at 18:19

101 Answers 101

1 2 3
4
4
\$\begingroup\$

1989 - Bash

Bash (sometimes called Bourne Again Shell ) is famous unix/linux shell. It introduced by Brian cox for GNU Project in 1989. It practically default shell in most of linux distributions.

Task 1

echo "Bash was made in 1989"

Task 2

ascii() {
    n=$1
    i=0
    while [  $i -lt $n ]; do
        j=0
        while [  $j -lt $n ]; do
            v=$(($n-1))
            if [ "$j" -eq "0" ] || [ "$j" -eq "$v" ] || [ "$i" -eq "$j" ]; then
                echo -n "N"
            else
                echo -n " "
            fi
            j=$((j+1))
        done
        echo ""
        i=$((i+1))
    done
}

# Usage 
ascii 5

Task 3

gcd() {
    a=$1
    b=$2
    retval=0
    if [ "$a" -ne "$b" ]; then
        if [ "$a" -gt "$b" ]; then
           let large=$a
           let small=$b
        else
           let large=$b
           let small=$a
        fi
        while [ $small -ne 0 ]; do
            let m=$(($large % $small))
            let large=$small
            let small=$m
        done
        retval=$large
    fi
}

# Usage
gcd 8 12
echo $retval

Improved version of Task 3

gcd() {
    a=$1
    b=$2
    retval=0
    while [ $a -ne $b ]; do
        if [ "$a" -gt "$b" ]; then
            let a=$a-$b
        else
            let b=$b-$a
        fi
    done
    retval=$a
}

gcd 8 12
echo $retval

Disclaimer : I have no manual/version to check if following code also work for initial versions.

\$\endgroup\$
1
  • \$\begingroup\$ Why not just the obvious solution? gcd() { if [ $2 == 0 ] ; then echo $1 ; else gcd $2 $(($1 % $2)) ; fi } \$\endgroup\$
    – marinus
    Apr 17, 2015 at 18:41
4
\$\begingroup\$

2013 - Pyret

Pyret is a scripting language designed for educational purposes. It was created by the team behind Racket and has a Python-inspired syntax. It encourages programming in a functional style through features such as pattern matching and algebraic data types. Unit testing is a first-class feature of the language.

Task 1 - Hello World

print("Pyret was made in 2013!")

Task 2 - Ascii Art N

fun ascii_art_n(size):
  if size == 1:
    print("N")
  else:
    outer = "N" + string-repeat(" ", size - 2) + "N"
    print(outer)
    range(1, size - 1).each(
      lam(row): print("N" + string-repeat(" ", row - 1) + "N" + string-repeat(" ", size - 2 - row) + "N")
      end)
    print(outer)
  end
end  

Task 3 - GCD

fun gcd(a, b):
  if b == 0:
    a
  else:
    gcd(b, num-modulo(a, b))
  end
end

print(gcd(8, 12))
print(gcd(12, 8))
print(gcd(3, 30))
print(gcd(5689, 2))
print(gcd(234, 876))
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Well, that can't possibly cause headaches, - as a valid character within names... \$\endgroup\$ Apr 28, 2015 at 13:45
  • 3
    \$\begingroup\$ @ɐɔıʇǝɥʇuʎs - From the Pyret Style Guide: 'Most languages can’t support dashes because the dash also stands for infix subtraction. In Pyret, subtraction must be surrounded by space. Therefore, camel-case is a name whereas camel - case is subtraction.' \$\endgroup\$
    – pmarflee
    Apr 29, 2015 at 15:23
3
\$\begingroup\$

2008 - Nim

Nim (formally "Nimrod") is a statically typed, imperative programming language. It is designed as a modern systems programming language, combining runtime efficiency with an expressive syntax.

Hello World!

No ceremony required here. We use the echo function from the system module that is automatically imported for all programs to write a message to stdout.

echo "Nim was made in 2008!"

Ascii Art N

This program expects a single command-line argument that is the size of the letter N to produce. Nim's expressiveness is demonstrated by the use of list comprehensions to generate the list of values to enumerate over. stdout.write is used instead of echo so that a newline character is not written to stdout after printing each character.

from os import paramStr
from strutils import parseInt

let size = parseInt(paramStr(1))

for i in 1..size:
  for j in 1..size:
    if j == 1 or j == i or j == size:
      stdout.write 'N'
    else:
      stdout.write ' '
  stdout.write "\n"

The following statement, run from the console, will generate a letter N of size 10:

nim c -r ascii_art_n.nim 10

GCD

Not much to say here. Note the use of the implicit variable result that is used to return a value from the function.

proc gcd(a: int, b: int): int =
  if b == 0:
    result = a
  else:
    result = gcd(b, a mod b)

echo gcd(8, 12)
echo gcd(12, 8)
echo gcd(3, 30)
echo gcd(5689, 2)
echo gcd(234, 876)    
\$\endgroup\$
3
\$\begingroup\$

1993 - Excel VBA

Task 1

MsgBox "VBA was made in 1993!"

Task 2

 n = InputBox("Please enter n")
Cells(1, 1).Select
ActiveCell.Value = "N"
For i = 0 To n - 1
    ActiveCell.Offset(i, i).Value = "N"
    Cells(i + 1, 1).Value = "N"
    Cells(i + 1, n).Value = "N"
Next

Task 3

x = InputBox("Please enter first integer")
y = InputBox("Please enter second integer")
Do While y <> 0
    t = y
    y = x Mod y
    x = t
Loop    
Gcd = x    
MsgBox Gcd
\$\endgroup\$
1
  • \$\begingroup\$ You should probably add that you'll need references to an Excel object library for this to work. It's not standard across all VBA! \$\endgroup\$ Sep 9, 2015 at 14:20
3
\$\begingroup\$

2012 - Elixir

Elixir is a functional, concurrent, high-level general-purpose programming language that runs on the BEAM virtual machine, which is also used to implement the Erlang programming language. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.

Task 1 - "Hello, World!" Variant

IO.puts "Elixir was made in 2012!"

Task 2 - ASCII Art N

Here's a simple way to draw an ASCII "N" in Elixir:

defmodule Main do
  def ascii(n) do
    0..(n - 1)
    |> Enum.each(fn i ->
      s = String.duplicate(" ", n - 2)
      s = "N" <> s <> "N"
      s = replace_at_index(s, i, "N")
      IO.puts(s)
    end)
  end

  defp replace_at_index(s, i, replacement) do
    pre = String.slice(s, 0, i)
    post = String.slice(s, i + 1, String.length(s))
    pre <> replacement <> post
  end
end

Main.ascii(5)

This will output:

N   N
NN  N
N N N
N  NN
N   N

Try it online!

Task 3 - GCD

Here's how to find the greatest common divisor (GCD) of two numbers in Elixir using the Euclidean algorithm:

defmodule Main do
  def gcd(a, 0), do: a
  def gcd(a, b), do: gcd(b, rem(a, b))
end

IO.puts Main.gcd(48, 18)

This script will output 6, which is the GCD of 48 and 18.

Try it online!

\$\endgroup\$
2
\$\begingroup\$

1998 - C++98

Bjarne Stroustrup created C++ after his work on the predecessor C with Classes which an extension of C and some other languages. In 1998, ISO standardised C++ and later released C++03 in 2003 with some bug fixes, but from a programmer's perspective there's little difference according to his FAQs:

http://www.stroustrup.com/bs_faq.html#C++03

Hello world

void H(){std::cout<<"C++ was made in 1998!\n";}

N in ACSII

void N(int n)
{
char x;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
x=' ';
if(j==0||i==j||j==n-1)x='N';
std::cout<<x;
}
std::cout<<std::endl;
}
}

GCD

void G(int x, int y)
{
int d=1,g=1;
int m=(x<y)?x:y;
do
{
g++;
if(x%(g)==0 && y%(g)==0)d=g;
}
while(g<=m);
std::cout<<d;}

Tests

#include <iostream>   
int main()
{
    H();
    int n;
    std::cin>>n;
    N(n);
    int a,b;
    std::cin>>std::skipws>>a>>b;
    G(a,b);

    return 0;
}

Edit Fixed as suggested in comments

\$\endgroup\$
3
  • 4
    \$\begingroup\$ I'd suggest calling this C++98 because as is your language name is read as "Standard C++ C++ Wiki". It would also be best if you can explain a bit about how C++98 differs from other versions of C++ and if any of those differences are present in your code. Otherwise posting this 1998 standard of C++ doesn't mean much. \$\endgroup\$ Apr 13, 2015 at 21:09
  • \$\begingroup\$ @Calvin'sHobbies what's wrong with it now? \$\endgroup\$ Apr 14, 2015 at 2:56
  • 3
    \$\begingroup\$ The std namespace and new header names like <iostream> are specific to Standard C++, which would be good to note in the answer. Speaking of the latter, this code has some problems, like missing #include directives, and main() declared as void (instead of int), which makes this code very much not Standard C++. \$\endgroup\$ Apr 16, 2015 at 1:35
2
\$\begingroup\$

2015 - Pip

Task 0:

Pip is fun. I just recently found out about it, but the first commits on github are from 2015. It was created by dloscutoff, who states that it exists to make golfing easier, and to that end it: "1) is imperative, and 2) uses infix operators"

Task 1:

"Pip was made in 2015"

Task 2:

b:qFa,b{Fc,b{(c=0|c=b-1|c=a)?O"N"Os}Ps}

Try it online!

Task 3:

a:qb:qWb{t:bb:a%ba:t}a

Try it online!

I might add explanations if I have time later. Fun question, thanks!

\$\endgroup\$
1
\$\begingroup\$

2013 - Wren

Wren is a language invented in 2013. I am not sure why it is created, but as far as I can tell, the author says that it is a very lightweight language. As a result this is very fast; it can beat the speed of Lua.

I have nothing more to say, I'll just copy the sentences verbatim from the blogs.

Like the bird, Wren’s ecosystem is small but full of life. Almost everything is under active development and there’s lots to do. Staying small, simple, learnable and hackable is all vital to what makes Wren valuable, and will remain.

Hi Wren!

System.print("Wren was made in 2013!")

Try it online!

ASCII Art

See, just one for loop will do this job!

Fn.new{ |N|
    for(i in 1 .. N) {
        var a = "N" +
      " " * (i - 1) +
                "N" +
      " " * (N - i) + "N"
        System.print(a.replace("NN","N").
                     replace("N " ,"N"))
    }
}

Try it online!

GCD

Unfortunately Wren does not support recursion. :( This uses iteration instead.

Fn.new{ |a, b|
    var t

    while(a % b != 0) {
        a = a % b
        t = a
        a = b
        b = t
    }

    return b
}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

1987 - Erlang

The testing version of Erlang was released to the public on 1987.

Erlang is a multipurpose programming language designed for concurrency and distributed systems. It is designed to be easy to learn and use, and it's special for its error-tolerance.

Task 1


main([]) -> io:fwrite("Erlang was made in 1987!").
% Just a boring fwrite of the string.

Try it online!

Task 2


loop(A, 0) -> "";                         % Ending condition: If N is 0,
                                          % exit the loop
loop(A, N) -> loop(A+1, N-1)              % Otherwise, prepend loop(A+1,N-1)
                                          % to the following string:
           ++ "N"                         % Concatenate with string "N"
           ++ string:slice (              % Slice the following string:
                  string:copies(" ", N-1) % Repeat " " N-1 times
               ++ "N"                     % Append "N"
               ++ string:copies(" ", A),  % Repeat " " A times
               1, A+N-2)                  % Remove the beginning & end
                                          % of the string
           ++ "N~n".                      % Append "N" plus a newline
loop(N)    -> loop(0, N).                 % For the input number,
                                          % get into the loop
main([])   -> io:fwrite(loop(7)).         % Test section

Try it online!

Task 3

Nice & simple.


gcd(A, 0) -> A;                      % If B is 0, return A.
gcd(A, B) -> gcd(B, A rem B).        % Otherwise, return gcd(B, A%B).
main([]) -> io:write(gcd(234,876)).  % Test section

Try it online!

\$\endgroup\$
1
\$\begingroup\$

1970 – Pascal

The programming language Pascal is named in honor of the French mathematician Blaise Pascal (1623 – 1662). It is an imperative programming language developed by Niklaus Wirth at the ETH Zürich, a technical university in Switzerland.

At its surface Pascal has been designed to be a programming language suitable for teaching programming to students (e. g. heavy use of natural language keywords). Accounting for the limited computing resources in the era of development, another design consideration is suitability for a single-pass translator. For instance all identifiers need to be declared beforehand.

There were many implementations, e. g. UCSD Pascal (UCSD stands for University of California, San Diego). With Turbo Pascal of the company Borland, a dialect of Pascal gained a significant and lasting user base outside of education.

To counter the mess dialects caused, in 1990 Pascal was standardized by the ISO standard 7185 Standard Pascal and ISO standard 10206 Extended Pascal (in addition to almost equivalent standards of some national standardization authorities), making it one of the few programming languages with an ISO standard.

As of 2022, Pascal lives on in the commercial Delphi compiler, a successor of Turbo Pascal, and FreePascal Compiler.

program helloPascal(output);
    begin
        writeLn('Pascal was made in 1970!')
    end.
{ Note, this is Pascal as described in The Programming Language Pascal
  (Revised Report) published in July 1973. There it says:
  
  “The two textfiles input and output are understood to be predefined
  as parameters and must not be listed explicitly.”

  In Pascal as defined by the ISO standards 7185 and 10206
  this implicit assumption is not the case. }
program printVariableHeightCapitalN;
    { The permitted values of the built-in data type `integer` are a
      subset of whole numbers (ℤ) defined by the individual implementation.
      Some implementations may experience difficulties with `set of integer`.
      For those implementations you may need to restrict/redefine `integer`:
    type
        integer = 1..255; }
    var
        { In Pascal all identifiers need to be declared beforehand. }
        N, line: integer;
        M: set of integer;
    begin
        { This is short for  `readLn(input, N)`
          which is short for `read(input, N); readLn(input)`.
          The `readLn` discards input until/including an end-of-line marker.
          Thus it is legal to type: 7 Hello World! <enter> }
        readLn(N);
        
        if (N > 0) and odd(N) then
            { In Pascal `for`-loop limits are _inclusive_.
              This is similar to the ∏ and ∑ notation limits in mathematics. }
            for line := 1 to N do
            { A `begin` … `end` frame is only necessary if multiple statements
              ought to be grouped _together_ as _one_ statement.
              This loop needs it, but the following nested loop does not. }
            begin
                { This is a `set` literal.
                  Recall that writing `[1, 1, 1, 1]` is identical to `[1]`. }
                M := [1, line, N];
                
                for N := 1 to N do
                    { For some variation (instead of an `if`-statement): }
                    case N in M of
                        true:
                            write('N')
                        ;
                        false:
                        begin
                            { `read`/`readLn` and `write`/`writeLn`
                              offer some goodies, but there are also
                              some “low-level” procedures available.
                              `output↑` denotes the buffer variable
                              associated with the `text` file `output`. }
                            output↑ := ' ';
                            put(output)
                        end
                    end;
                { Notice the lack of trailing semicolons.
                  In Pascal a semicolon _separates_ statements from each other
                  which is evidently not necessary if there are no further. } 
                writeLn
            end
    end.
program greatestCommonDivisor;
    var
        n, m, r: integer;
    begin
        readLn(n, m);
        
        { Pascal makes a clear distinction between `:=` – an assignment –
          and `=` – a comparison for equality. }
        repeat
            { The `repeat` … `until` already constitutes a frame,
              so it is not necessary to write `begin` … `end` here. }
            r := n mod m;
            n := m;
            m := r
        until r = 0;
        
        writeLn(n)
    end.
\$\endgroup\$
0
\$\begingroup\$

05AB1E - 2015

"Hello, World!" Variant

0•5¶Ï•h«…€¥ƒ›€†Ž7ç'!«ðý

Try it online!

0•5¶Ï•h«…€¥ƒ›€†Ž7ç'!«ðý  # full program
       «                 # join...
 •5¶Ï•                   # 371486...
      h                  # in hexadecimal...
       «                 # with...
0                        # literal
        …€¥ƒ›€†          # push "was made in"
                    «    # join...
               Ž7ç       # 2015...
                    «    # with...
                  '!     # literal
                      ý  # join stack by...
                     ð   # spaces
                         # implicit output

ASCII Art N

Θi'Nëð¹Í×'N©.ø¹<GðN<×®«ð¹N-Í׫®.ø}ð¹Í×®.ø}»

Try it online!

Θi'Nëð¹Í×'N©.ø¹<GðN<×®«ð¹N-Í׫®.ø}ð¹Í×®.ø}»  # full program
 i                                           # if...
                                             # implicit input...
Θ                                            # is 1...
  'N                                         # push literal
    ë                                        # else...
            .ø                               # surround...
         'N                                  # literal...
           ©                                 # (also store in register_c)...
            .ø                               # with...
      ¹                                      # input...
       Í                                     # minus 2...
     ð  ×                                    # spaces
                G                            # for N in [1, 2, ...,
              ¹                              # ..., input...
               <                             # minus 1...
                G                            # minus 1]...
                               .ø            # surround...
                             «               # joined...
                      «                      # joined...
                  N                          # variable...
                   <                         # minus 1...
                 ð  ×                        # spaces...
                      «                      # with...
                     ®                       # register_c...
                             «               # with...
                        ¹                    # input...
                          -                  # minus...
                         N                   # variable...
                           Í                 # minus 2...
                       ð    ×                # spaces...
                               .ø            # with...
                              ®              # register_c
                                 }           # exit loop
                                       .ø    # surround...
                                   ¹         # input...
                                    Í        # minus 2...
                                  ð  ×       # spaces...
                                       .ø    # with...
                                      ®      # register_c
                                         }   # exit if statement
                                          »  # join stack by newlines
                                             # implicit output

GCD

¿

Try it online! Built-in function.

\$\endgroup\$
1 2 3
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.