loops - Print text multiple times in Brainfuck -
i tried out hello world program in brainfuck. how can print text multiple number of times? here's code:
+++++++[>++++++++++ <- ] >++.>++++++[>++++++++++ <- ] >+++++++++.>+++++++[>++++++++++ <- ] >++++++..>+++++++[>++++++++++ <- ] >+++++++++.>+++[>++++++++++ <-]>++. >++++++++[>++++++++++<-]>+++++++.>+++++++[>++++++++++<-] >+++++++++.>++++++++[>++++++++++ <-]>++.>+++++++[>++++++++++ <- ] >++++++.>++++++[>++++++++++ <-]>++++++++.>+++[>++++++++++<-]>++.>+++[>++++++++++<-]>+++.>+++[>++++++++++<-]>+++.
let's think of 5 character long word "hello".
so if want print 5 characters 3 times have code this:
,>,>,>,>,>+++[<<<<<.>.>.>.>.>-]
let me explain code:
the first part of code input part:
,>,>,>,>,
then initialize variable containing information want print 3 times.
>+++
then have loop goes start, prints out 5 characters, , goes variable , decrement it.
[<<<<< //goes .>.>.>.>. //print out >-] //decrement
if got idea, can improve code e.g. putting more loops in it, wanted show simple idea.
Comments
Post a Comment