@minx28/

Triangular Numbers

BrainF

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7297036134300032","path":"main.bf","file":{"path":"main.bf","content":{"asEncoding":{"base64":"LD4rKysrKytbPC0tLS0tLS0tPi1dPCAgICBUYWtlcyBhbiBpbnB1dCBvZiBhIERJR0lUIHRoZW4gc3VidHJhY3RzIDQ4IGJlY2F1c2UgdGhlIEFTQ0lJIHZhbHVlcyBvZiAxIHRvIDkgYXJlIDQ5IHRvIDU3Cls+Kz4rPDwtXSAgICBUcmFuc2ZlcnMgdGhpcyB2YWx1ZSB0byBjZWxscyAyIGFuZCAzCj5bIFVudGlsIGNlbGwgMiBpcyAwOiAKICA+Wz4rPis8PC1dICAgIFRyYW5zZmVycyB2YWx1ZSBvZiBjZWxsIDMgdG8gNCBhbmQgNQogID5bPDw8Kz4+Pi1dICAgIEFkZHMgdmFsdWUgb2YgY2VsbCA0IHRvIGNlbGwgMQogID5bPDwrPj4tXTw8LSAgICBUcmFuc2ZlcnMgdmFsdWUgb2YgY2VsbCA1IGJhY2sgdG8gY2VsbCAzIHRoZW4gc3VidHJhY3RzIDEKPC1dICAgIEdvIGJhY2sgdG8gY2VsbCAyIGFuZCBzdWJ0cmFjdCAxOyBsb29wCgpUaGlzIHByb2dyYW0gZG9lc24ndCBhY3R1YWxseSBwcmludCBhbnl0aGluZzsgaXQgcmVsaWVzIG9uIHRoZSBmYWN0IHRoYXQgdGhlIFJlcGxpdCBJREUgc2hvd3MgdGhlIG1lbW9yeSBhdCB0aGUgZW5kIG9mIHRoZSBwcm9ncmFtIGJlY2F1c2UgcHJpbnRpbmcgYSAyIGRpZ2l0IG51bWJlciBhcyAyIGRpZ2l0cyB3b3VsZCBiZSByYXRoZXIgZGlmZmljdWx0CgpUbyBjb21tZW50IGluIEJyYWluRiB5b3UgY2FuIHNpbXBseSB0eXBlIGxpa2UgdGhpcyBhcyB0aGUgcHJvZ3JhbSB3aWxsIGlnbm9yZSBhbnkgY2hhcmFjdGVycyB0aGF0IGFyZSBub3Qgb25lIG9mIHRoZSA4IGJ1dCB5b3UgaGF2ZSB0byBiZSBjYXJlZnVsIG5vdCB0byBpbmNsdWRlIGFueSBmdWxsIHN0b3BzIGNvbW1hcyBvciBvdGhlciBCcmFpbkYgY2hhcmFjdGVycw=="},"asBuffer":null},"loaded":true}}
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