Your task is simple. Post a snippet in any language that if the snippet is repeated n times, will output n in decimal, octal, and hexadecimal, in that order, separated in spaces. n is an integer larger than zero. There is no leading zeroes. Shortest answer wins

Example

If the snippet is ABC then the test case is

ABC
1 1 1
ABCABC
2 2 2
ABCABCABCABCABCABCABCABCABC
9 11 9
ABCABCABCABCABCABCABCABCABCABCABCABC
12 14 C
ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC
18 22 12
• Is it ok if I print 1 01 0x1? (Includes prefixes)
– Blue
Jan 2 '16 at 18:28
• If you have a language with implicit input/output, then you could have a 1 byte solution that just incremented the value... Dec 1 '16 at 5:00

printf"\r%d %o %x",++$n,$n,$n; Go back to the beginning of the line, increment counter and print counter overwriting the old output. • +1 for spotting a hole in specification, Output erasure make this challenge trivial. Jan 2 '16 at 5:07 • @ChristianIrwan: actually it's not erasing, but overwriting (I've corrected my description) – nimi Jan 2 '16 at 7:29 • That both ruins the challenge. Jan 2 '16 at 8:02 JavaScript, 54 53 51 47 bytes Saved 4 bytes thanks to @user81655 var d=-~d;d+${d[b='toString'](8)} +d[b](16);

I'm actually kinda surprised this works.

Explanation

var d=-~d;  // var let's d not throw an error if it's not defined
// -~ essentially increments the variable
d+                    // decimal

Once:

>> matl 0$N1+ttYUb8YAb16YA3$XhZc1$1 1 1 Twice: >> matl 0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$2 2 2 16 times: >> matl 0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$0$N1+ttYUb8YAb16YA3$XhZc1$16 20 10 Explanation The number of elements in the stack is used to indicate how many times we've run the snippet 0$         % specify zero inputs for next function, in case this is not the first
% occurence of the snippet.
N          % number of elements in stack
tt         % duplicate twice. We now have three copies of the number
YU         % convert to string (decimal)
b8YA       % bubble up number and convert to octal string
b16YA      % bubble up number and convert to hex string
3$XhZc % join top three elements (strings) with a space 1$         % specify one input for next function. If the program ends here, that next
% function will be implicit display, so it will print the top of the stack.
% Else the stack will be left with one element more than at the beginning of
% the current snippet

OCaml, 198 bytes

;;open Char
;;(if Sys.argv.(0).='~'then Sys.argv.(0).<-'\000'else Sys.argv.(0).<-chr(1+int_of_char Sys.argv.(0).));let n=1+int_of_char Sys.argv.(0).in Printf.printf"\r%d %o %x"n n n

Includes a trailing newline and requires that the filename starts with a tilde (I used ~.ml; you can run it with ocaml \~.ml) because it's the highest-valued standard printable ASCII character. Abuses the fact that all characters in a string are mutable and Sys.argv.(0). is the first character in the filename.

It should only work for n = 1 to 126, because the ASCII code for ~ is 126 and I'm adding one to the output. It could be made two bytes shorter if we only want n = 1 to 125. After it's repeated 126 times, it'll cycle back to n = 1.

This is my first ever golf so any comments or improvements would be much appreciated.

Ungolfed version:

;; open Char
;; if Sys.argv.(0). = '~'
then Sys.argv.(0). <- '\000'
else Sys.argv.(0). <- chr (1 + int_of_char Sys.argv.(0).)
;; let n = 1 + int_of_char Sys.argv.(0). in
Printf.printf "\r%d %o %x" n n n
• +1 The ,many holes in my question make me choose to downvote my own question. (I can't do that, though.) Jan 3 '16 at 5:05
• I'm suspicious about repeated Sys.argv.(0).. I don't know much about OCaml, though. Jan 3 '16 at 5:06

TeaScript, 21 20 bytes

[┼d,dT8),dT16)]j(p);

I should make it auto-close on ;

Try it online

Explanation

becomes ++

// Implicit: d = 0
[   // Start array
++d,  // Increment d, decimal value
dT8),  // d to base 8
dT16)  // d to base 16
]j(p); // Join by spaces
// Implicit: Output *last* expression
• Downvote? Is there something wrong with this answer? Does it have to do with ASCII Character Jumble as that also got downvoted within minutes of this if not less Jan 2 '16 at 20:30

$_=<<'';printf"%d %o %x",(1+y/z//)x3; : There's a final newline behind the colon. Treats everything after the first line as a here document and counts the z in it. For every further copy of the code one z is added. We have to add 1 to the count, because there's none for the first snippet (the one that is executed). If additional output to stderr is allowed, we can omit the 2 single quotes '' and can get down to 38 bytes. Without the '' perl emits a warning about a deprecated feature. Mathematica, 76 bytes Note that n should have no definitions before. 0;If[ValueQ@n,++n,n=1];StringJoin@Riffle[IntegerString[n,#]&/@{10,8,16}," "] Here, the behaviour of ; is used. The snippet above is one single CompoundExpression, however, when a couple of snippets are put together, there is still one CompoundExpression as is shown below. (Some unnecessary rearrangements are made.) 0; If[ValueQ@n,++n,n=1]; StringJoin@Riffle[IntegerString[n,#]&/@{10,8,16}," "] 0; If[ValueQ@n,++n,n=1]; StringJoin@Riffle[IntegerString[n,#]&/@{10,8,16}," "] 0; If[ValueQ@n,++n,n=1]; StringJoin@Riffle[IntegerString[n,#]&/@{10,8,16}," "] (* 3 3 3 *) So one cannot make such snippet works if writting explicit CompoundExpression. Also, almost everything you like can be put before the first ; such as E, Pi or MandelbrotSetPlot[],. bash, 49 bytes File count.bash: ((++n));trap 'printf "%d %o %x\n"$n $n$n' exit;

...no trailing newline.

Run:

$bash count.bash 1 1 1$ cat count.bash count.bash count.bash | bash
3 3 3
$for i in$(seq 10) ; do cat count.bash ; done | bash
10 12 a

Python 2, 54 bytes

No trailing newline. Outputs in the form 1 01 0x1.

If that's not ok, 56 bytes

When pasted in front of each other, the length of the file gets longer by 1 line for each time pasted. The base case starts with 2 lines so you have to subtract 1 from the line length. Computation is suppressed by the comment.

• "%d %o %x"%(n,n,n), that is pretty cool. I had no idea you could do that. If it turns out that leaving prefixes is not ok I'm going to have to borrow that. Jan 3 '16 at 7:20

Python 2.x 140 bytes

This was not meant to be an overly competitive solution, but a method that I found amusing, being for one thing, an attempt at a multithreaded code golf.

def t(c):99**99;print("%s "*3)%(n,oct(n),hex(n))*(c==n)

Keeps a counter, spawns a thread for each count and if the counter has not changed when the counters timer goes off after a completing an expensive math problem (instead of a timer to save bytes), the formatted string is printed.

Some example configurations and their outputs:

def t(c):99**99;print("%s "*3)%(n,oct(n),hex(n))*(c==n)

Outputs 1 01 0x1

and fifteen copy pastes:

def t(c):99**99;print("%s "*3)%(n,oct(n),hex(n))*(c==n)