Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Brainfuck, 24 Bytes.

Brainfuck, 24 Bytes.

I/O is handled as bytes.

,[[->+>+<<]>[-<+>]<-]>>.

Explained

,[[->+>+<<]>[-<+>]<-]>>.
, # Read a byte from STDIN
 [ ] # Main loop, counting down all values from n to 1
 [->+>+<<] # Copy the i value to *i+1 and *i+2
 >[-<+>] # Move *i+1 back to i
 <- # Move back to i, lower it by one. Because *i+2 is never reset, each iteration adds the value of i to it.
 >>. # Output the value of *i+2

#Brainfuck, 24 Bytes.

I/O is handled as bytes.

,[[->+>+<<]>[-<+>]<-]>>.

Explained

,[[->+>+<<]>[-<+>]<-]>>.
, # Read a byte from STDIN
 [ ] # Main loop, counting down all values from n to 1
 [->+>+<<] # Copy the i value to *i+1 and *i+2
 >[-<+>] # Move *i+1 back to i
 <- # Move back to i, lower it by one. Because *i+2 is never reset, each iteration adds the value of i to it.
 >>. # Output the value of *i+2

Brainfuck, 24 Bytes.

I/O is handled as bytes.

,[[->+>+<<]>[-<+>]<-]>>.

Explained

,[[->+>+<<]>[-<+>]<-]>>.
, # Read a byte from STDIN
 [ ] # Main loop, counting down all values from n to 1
 [->+>+<<] # Copy the i value to *i+1 and *i+2
 >[-<+>] # Move *i+1 back to i
 <- # Move back to i, lower it by one. Because *i+2 is never reset, each iteration adds the value of i to it.
 >>. # Output the value of *i+2
Source Link
ATaco
  • 11.7k
  • 30
  • 82

#Brainfuck, 24 Bytes.

I/O is handled as bytes.

,[[->+>+<<]>[-<+>]<-]>>.

Explained

,[[->+>+<<]>[-<+>]<-]>>.
, # Read a byte from STDIN
 [ ] # Main loop, counting down all values from n to 1
 [->+>+<<] # Copy the i value to *i+1 and *i+2
 >[-<+>] # Move *i+1 back to i
 <- # Move back to i, lower it by one. Because *i+2 is never reset, each iteration adds the value of i to it.
 >>. # Output the value of *i+2

AltStyle によって変換されたページ (->オリジナル) /