# Implement a Truth-Machine

A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

• Gets a number (either 0 or 1) from STDIN.

• If that number is 0, print out 0 and terminate.

• If that number is 1, print out 1 forever.

# Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

• take input from STDIN or an acceptable alternative
• If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program
• must output to STDOUT or an acceptable alternative
• If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.
• when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory
• the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

• if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

# Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

## Language Name, N bytes


where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes


If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes


You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes


<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 320px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62732; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 12012; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>

• Can we assume that the program halts when the processor finishes executing the written code, for a machine code entry? – lirtosiast Nov 3 '15 at 16:58
• Assuming any behaviour is fine for all invalid inputs? – Cruncher Nov 3 '15 at 17:33
• @Cruncher Yes, the only inputs you should expect to get are 0 and 1. – a spaghetto Nov 3 '15 at 17:38
• Catalog is borked. – Addison Crump Nov 6 '15 at 15:18
• Catalog appears to consider Bf and bf to be different languages. – Mooing Duck Nov 10 '15 at 1:13

## Gol><>, 5 bytes

IZh1n


Thanks to JoKing for helping golf this down further!!!

Try it online!

# Tamsin, 19 bytes

main="0"|{print 1}.


## Explanation

The main production first tries to read a 0. If it succeeds, it is returned, and, because this is the main production, printed.

Otherwise, it ignores the input and tries the alternative, which is {print 1}. The { } brackets denote a loop that continues running as long as its content succeeds, and a print statement always succeeds, so this loops forever.

# Python 3, 41 bytes

a=input()
while(a=='1'):print(1)
print(0)


Try it online!

# INTERCAL, 89 bytes

DOWRITEIN.1PLEASE.3<-#1$.1DOCOMEFROM(2)DOREADOUT.1(2)PLEASE(1)NEXT(1)DO(1022)NEXTDOGIVEUP  Try it online! Looking at some answers to this challenge, I noticed that the current INTERCAL answer was barely golfed at all, with 141 bytes 30 of which are whitespace. Not hard to outdo! Uses native INTERCAL-72 integer I/O, that is, the input is ZERO or ONE (or some translation thereof) with a trailing newline, and the output is in "butchered Roman numerals". Explanation: DO WRITE IN .1 Inputs a number to the 16-bit variable .1. PLEASE .3 <- #1$ .1

Sets .3's value to 1 mingled with .1's value. Since .1 holds either 0 or 1, .3 is set to either 2 or 3.

DO COME FROM (2)

If execution would move on normally from statement (2), it goes here instead.

DO READ OUT .1

Prints the value in .1.

(2) PLEASE (1) NEXT

This is statement (2). It places itself on the NEXT stack and moves execution to statement (1). It does not trigger the COME FROM unless RESUMEd to.

(1) DO (1022) NEXT

This is statement (1). It NEXTS to statement (1022) in syslib, which then itself NEXTS to statement (1023) in syslib, which reads PLEASE RESUME .3. This pops a non-zero number of entries equal to .3 off the NEXT stack and resumes execution at the last one popped. Since there are at this point three entries on the NEXT stack, corresponding to (2), (1), and (1022) (RESUME works just fine without labels, it just so happens that all of the NEXTs here have them), and .3 is 2 or 3 depending on whether .1 is 0 or 1, this goes to and moves on from either (1) if .1 is 0, or (2) if .1 is 1. If this RESUMEs to (2), the COME FROM takes effect and begins an infinite loop (and since this outcome leaves the NEXT stack empty, the program does not disappear into the black lagoon after 80 loops).

DO GIVE UP

If (1) was RESUMEd to, execution moves here, and this terminates the program without an error.

(I'll edit in a version with Turing Tape string I/O some time later.)

# NuStack, 82 bytes

putchar(c:char):int;f(i:int):int{if(i>0)putchar('1');else while(1>0)putchar('0');}


Been working on this compiler for a month and a half. Still very much a WIP, but finally at a point where I can do some PPCG with it :D

Unlike all of my other languages, this isn't some toy, esoteric, interpreted language.
It's a serious language that compiles directly to assembly (nasm syntax).

I'll probably opt to get NuStack on TIO once it's notably more feature-complete than it currently is.

## Explanation:

Ungolfed version:

putchar(c: char): int;

f(i: int): int {
if(i > 0)
putchar('1');
else
while(1 > 0)
putchar('0');
}


The first line is a function prototype that allows you to call a function defined elsewhere (think C header files)

putchar in particular is currently the only function in libns, the language's standard library. It takes a single char, and outputs it to stdout. libns is currently available for 64bit linux, so it just makes a syscall using sys_write(), and 32bit "raw", ie not running on a kernel or operating system, where putchar will use the int 0x10 interrupt to print the character in TTY mode

NuStack uses post-fix types, similar to TypeScript, and there is no type inference, so types must always be explicitly declared.

NuStack also doesn't have type casts yet, or do..while loops, so this is, as far as I know, the golfiest way to do it.

# GolfScript, 13 bytes

~{.}{.p}while


### Explanation

~       # convert STDIN to an integer

{.}     # while loop condition: remains the same--the input
{.p}    # while loop body: print the input
while


This is one of my first golfs!

# Ruby + -np, 16 12 bytes

p 1while~/1/


Try it online!

~/1/ matches the last line of input to the regular expression /1/

Edit: replaced ;p 0 with the -p flag making the answer -np complete, thanks to @ValueInk

• you don't have to count flags any longer; just note in the body which one you've used (as you already have done) – Giuseppe Mar 5 '18 at 23:14
• @Giuseppe thanks, is this the consensus opinion now? – Asone Tuhid Mar 5 '18 at 23:16
• Yeah, see here. – Giuseppe Mar 5 '18 at 23:18
• @Giuseppe so should I call it Ruby + -n? – Asone Tuhid Mar 5 '18 at 23:28
• Use the -p flag instead to implicit print the zero ;p – Value Ink Jun 5 at 2:10

## Enterprise, 128 bytes

/©©//NDANDA/final disruptive class fdcBit{final immutable void main(){var Money i=read();;;write(i);;;while(i==1){write(i);;;}}}


It's really annoying how the specification isn't very clear, so I had to guess a lot of things.

## Keg, 1287 5 bytes

:[{:.


This duplicates an inputted string(the empty-: input mechanism was made to implement the Truth-machine). If the character is 1, output the character forever; otherwise output the character once. This indeed works. Try it online!

• This can now be 8 bytes due to implicit input – EdgyNerd Aug 10 at 9:30

# Rust compiler (nightly), 86 bytes

#![feature(log_syntax)]macro_rules!t{(0)=>{log_syntax!{0}};(1)=>{log_syntax!{1}t!{1}}}


(playground)

#![feature(log_syntax)]

macro_rules! truth_machine {
(0) => {
log_syntax!(0);
};
(1) => {
log_syntax!(1);
truth_machine!(1);
};
}

truth_machine!(0);
truth_machine!(1);


## Explanation

As the only way to iterate over anything other than the inputs of a macro is recursion, an infinite loop will always end in a stack overflow. I'm considering this error message "constant output of your language's interpreter that cannot be suppressed," as there's no other way to "infinitely" loop. The time for this to occur is dependent on the stack size, and thus most real-world macros will attempt to perform multiple operations per iteration to avoid this. Since this takes more space, I didn't do this. The only ways for a macro to give output are:

• compile_error!, a builtin which will immediately terminate compilation with a message, and is thus not valid for this challenge
• log_syntax!, an unstable builtin which will print its input to the compiler's stdout, with a newline appended
• Returning a value from the macro directly, which directly conflicts with the concept of an infinite loop

I chose to use log_syntax!, as I decided it was the only option that would follow the rules of the challenge. However, it requires a nightly compiler, and 23 additional characters in the source to enable. The syntax of macros is pretty fixed, but one trick I found is that macros called with macro!{} instead of macro!(); do not require a semicolon after, and are thus one character shorter.

?1/
#?
&#|


Try it online!

My first submission with my new language Cascade! Cascade is a tree-like esolang, similar to Pyramid Scheme, but a bit terser and with wrapping boundaries. Ungolfed, this looks more like:

 @ |
? /
#|
&|
^
# |
1 |


First, the ? checks if the printed (#) input (&) is positive. If not, it goes left and terminates since it finds no more instructions. If so, it goes right to the ^, which first executes the left (#1, print 1), then goes to the right, which wraps around back to the ^ for an infinite loop. In the golfed code we use another ? which does a similar thing except with the center and the right, since we know the return value of # is always positive.

# MathGolf, 5 4 3 2 bytes

-1 for dropping block marker

q▲


## Explanation

Implicit input
Starts a block
q  Output TOS without a newline.
▲ Execute the code block while the TOS is true. Executes at least once.
Implicit output


Try it online!

• I think you can drop the Ä since there's nothing before it now. – Unrelated String Oct 13 at 3:16

# Lua For windows, 70 bytes

Use lua for windows for this

I=io.read() If I=="1" then while 1 do print"1" end elseif print"0" end


This program works because it takes a 0 or 1 from stdin then if it's a one it makes a while loop that prints one if it's a 0 it prints 0 then the program ends

• Does this rely on functionality specific to Windows? Why couldn't this be run with Lua on other systems? – Alex A. Nov 4 '15 at 3:16
• This could be shorter if you just called If io.read()=="1" instead of assigning it to an alias. – James Murphy Nov 4 '15 at 5:41

## Ceylon, 91 88 bytes

Improved (explanation at the end):

shared void run()=>("0"<(process.readLine()else"")then{1}.cycled else{0}).each(print);

This was the original (91 bytes):

shared void run(){if("0"<(process.readLine()else"")){while(0<1){print(1);}}else{print(0);}}

Unfortunately the most part goes to reading the input and making sure it is defined.

shared void run() {
while(0<1) {
print(1);
}
} else {
print(0);
}
}


I merged this null check (in the else "" form) with the decision into one if, so when the input is ended without a line being read, it also prints 0. Also, any string sorting less than "0" lexicographically prints 0, and any string lexicographically > "0" will produce the 1-loop.

The 0<1 is used instead of true because it is shorter.

Here is a functional approach, unfortunately it can't compete (107 bytes after whitespace removal) due to the length of parseInteger:

shared void run() {
value i = parseInteger(process.readLine() else "") else 0;
(1:i).cycled.follow(i).each(print);
}


It cycles a range starting at 1 of length i (i.e. either {} or {1}), resulting in {} or {1,1,1,1,...}, prepends i (which results in {0} or {1,1,1,1,1,1,...}), and prints each element.

A different functional approach without variables and parsing is this one (88 bytes, shrinked version at the top):

shared void run() =>
("0" < (process.readLine() else "") then
{ 1 }.cycled else { 0 }).each(print);


This does the case distinction in an expression, using the then and else operators to produce either the {1,1,1,...} stream or the {0} singleton, and then calls print(...) on each element of that stream.

## C#, 120 98 bytes

using c=System.Console;class o{static void Main(){if(c.Read()=='1')for(;;c.Write(1));c.Write(0);}}


Ungolfed:

using c=System.Console;
class o
{
static void Main()
{
for(;;c.Write(1));
c.Write(0);
}
}

• 2-byte gain: int a=c.Read();do c.Write(a-48);while(a>48); – LegionMammal978 Dec 6 '15 at 16:10
• 95 bytes based on @LegionMammal978 answer using c=System.Console;class P{static void Main(){int a=c.Read()-48;do c.Write(a);while(a>0);}} – krontogiannis Aug 29 '16 at 10:26

## x86 (Linux / NASM syntax), 86 bytes

mov dx,1              ; 3rd argument to read(): length of buffer
mov ecx,esp           ; 2nd argument to read(): the buffer
mov ax,3              ; read system call number
int 128               ; invoke syscall, returns eax=1 == num of read bytes
l:mov ax,4            ; start of loop, eax=syscall number of write()
int 128               ; invoke syscall, returns eax=1 == num of written bytes
cmp byte[esp],49      ; compare buffer against '1'
jz l                  ; loop of it's the same
int 128               ; invoke syscall otherwise (syscall 1 == exit)


Compile with nasm -f elf h.asm && ld -o h h.o -m elf_i386 and ignore all warnings. :-)

## Swift, 187 bytes

import Foundation
let i = Int("\(String(data: NSFileHandle.fileHandleWithStandardInput().availableData, encoding: NSUTF8StringEncoding)!.characters.first!)")!
print(i)
while i>0{print(i)}


Sadly this has to read from stdin if it can :( Would be so much smaller if I could just declare it inside...

• Can you not remove the spaces around =, after :, and after ,? – Esolanging Fruit Dec 14 '17 at 0:36

## Scala, 46 bytes

if(readInt==0)print(0)else while(2>1)print(1)


Kinda uninteresting and obvious, but there we go

• ==0 can be replaced with <1 – V.G. Nov 12 '15 at 17:18
• val k=readInt;do{print(k)}while(k>0) – V.G. Nov 12 '15 at 17:24

# Atari Basic, 47 bytes

If I remember the syntax correctly, it will be something like this:

1 input a$2 IF a$="0" THEN end
3 ? a$4 goto 3  Please correct me if I'm wrong. • Do you need some spaces? ("0" THEN, ? a$) – Erik the Outgolfer Jul 22 '16 at 12:35
• @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I'm not sure, i produced this snippet from memory, i did't use atari basic for over 25 years. – user902383 Jul 22 '16 at 12:41

## Python 2, 46 bytes 34 bytes

x=input()
print x
while x:print x


Basically, it takes in the input, when 1, prints forever (while loop), but if it isn't 1 (when it is zero) it prints and then exits.

This is my first answer! Yay!

## Java, 90 97 bytes

class T{public static void main(String[]a){while(a[0].equals("1"))System.out.println(1);}}


I'm not sure if this counts because it takes 1 or 0 as an argument rather than STDIN. It's been emotional, either way.

Edit: The above does not print zero, the below does:

class T{public static void main(String[]a){do System.out.println(a[0]);while(a[0].equals("1"));}}

• You can save two characters by using print instead of println. (There was no requirement saying each 1 must be on a new line). Also, the command line can be added easily as while(a[0].equals(new java.util.Scanner(System.in).nextLine()). However, I don't think this meets the requirement, since it doesn't print 0. – Xynariz Nov 10 '15 at 1:42
• Fixed to print zero in 97 bytes. I had to use println because print must just be appending to the string so never actually prints a line for me. – ESP Nov 11 '15 at 9:45
• "print must just be appending to the string" .. .what? print and println do exactly the same thing, except that println prints the text plus the current OS's line delimiter. See the documentation: docs.oracle.com/javase/8/docs/api/java/io/… and docs.oracle.com/javase/8/docs/api/java/io/… – Xynariz Nov 13 '15 at 0:42
• @Xynariz You should only read the input once – SuperJedi224 Jan 3 '16 at 13:35
• @SuperJedi224 Um ... how is that even relevant to what I said? – Xynariz Jan 4 '16 at 20:57

## VB.NET, 106 Bytes

Imports c=System.Console
Module m
Sub Main
1:c.Write(i)
if i=1 then goto 1
end sub
end module


Straightforward, using goto instead of a loop. Compiles with Option Explicit and Option Strict Off, and Option Infer On

## STATA, 31 bytes

di _r(a)
m
do{$a }while($a)
end


First, get input from the user and store it in global variable a. Then switch to Mata for better commands. Print the value of a and then if it is truthy (i.e. 1), go to the start of the loop. If the end keyword is omitted, unexpected end of file (end statement missing) is output to standard error. I'm not sure if that's okay.

# Julia, 45 chars

readline()[1]>48?while 1>0 show(1)end:show(0)


# Staq, 5 chars

'[:]:


Explanation

'         input number, put it on top of the active stack
[        jump to corresponding ] if the top stack value = 0 or nonexistent
:       output top stack value as number
]      jump back to corresponding [ if top stack value >0
:     output top stack value as number


# Cardinal, 8 chars

%:> J.jN


Explanation

%                     create pointer
:                    enter number, put it on top of stack
>                   redirect pointer to the right
NOP
J                 skip next instruction if top stack value is > 0
.                output number to STDOUT
j               skip next instruction if top stack value is = 0
N              reflect pointer to the left


The original interpreter, written by Madk, is buggy, and some instructions are missing. I fixed the errors and recompiled the interpreter.

You can clone the fixed interpreter and readme from my GitHub repository.

• Does it use anything implemented after the question was asked? I think so. Sadly I think this is noncompeting. – Yet Another User Jan 7 '16 at 5:15
• @YetAnotherUser Cardinal is from 2010. Madk’s original interpreter (in BlitzMax) contains bugs that break the use of Cardinal, and he forgot to implement one or two commands that exist in his language spec. I fixed these errors and recompiled the fixed source in BlitzMax. Now everything works according to his specification. This is a catalog, the date of implementation does not matter. I uploaded my fix on GitHub yesterday, so everyone can enjoy it. The language is 5 years old; I fixed the errors around June 2015, as you can see e.g. here – M L Jan 7 '16 at 11:49

# Mouse16, 10 bytes

?0+[1!4\]0


Asks for input, then coerces it to an int and tests its truthiness. Then, if it's truthy, 1 is printed and the execution jumps to the 4th byte, where 1 is printed again, and so on forever (until the stack overflows), otherwise, 0 is printed.

# Pike, 94 bytes

Looks like C, but isn't C. Is interpreted. Is fast.

int main(){int x=(int)Stdio.stdin->gets();if(x!=0){for(;;){write("1");}}write("0");return 0;}


Ungolfed:

int main() {
int x = (int)Stdio.stdin -> gets();
if (x != 0) {
for(;;) {
write("1");
}
}
write("0");
return 0;
}

• I always want to pronounce Stdio as Studio :) Can you not write an integer to output? – ETHproductions Jan 22 '16 at 17:26
• @ETHproductions before I actually learned C, I always assumed stdio.h was some sorta studio something because of Visual Studio... I dunno. To write a number to stdout as far as I can tell you need to use write("%d", x); because write wants a string or array(char) argument, which is even longer – cat Jan 22 '16 at 17:29

## Boo, 34 bytes

def f(x):
print x;while x:print x


Boo is a language inspired by Python and implemented in .NET. Its syntax is very similar to Python 2's.

# CJam, 16 bytes

qi1={"1o_~"_~}&0