repl.it
@minx28/

Triangular Numbers

BrainF

No description

fork
loading
main.bf
1
2
3
4
5
6
7
8
9
10
11
,>++++++[<-------->-]<    Takes an input of a DIGIT then subtracts 48 because the ASCII values of 1 to 9 are 49 to 57
[>+>+<<-]    Transfers this value to cells 2 and 3
>[ Until cell 2 is 0: 
  >[>+>+<<-]    Transfers value of cell 3 to 4 and 5
  >[<<<+>>>-]    Adds value of cell 4 to cell 1
  >[<<+>>-]<<-    Transfers value of cell 5 back to cell 3 then subtracts 1
<-]    Go back to cell 2 and subtract 1; loop

This program doesn't actually print anything; it relies on the fact that the Replit IDE shows the memory at the end of the program because printing a 2 digit number as 2 digits would be rather difficult

To comment in BrainF you can simply type like this as the program will ignore any characters that are not one of the 8 but you have to be careful not to include any full stops commas or other BrainF characters
BrainF***, bfjs Copyright (c) 2011 Amjad Masad