# Write some code...

Write a program that takes no input and outputs an integer n which is a multiple of 3. So n=3k, where k is a positive integer.
Double the last character of your code.
Your code should then output k.

# Examples

Here is my program hui#2(21+4)//lm, which outputs 81. Because of that, hui#2(21+4)//lmm should output 27.
or
If p8$w2*8 outputs 9, p8$w2*88 should output 3.

# Rules

This is , shortest answer in bytes wins!

• Can it output 9.0 and 3.0? (Taking square roots, so it automatically turns into a float. :P) Aug 27, 2017 at 1:02
• This is a less interesting version of double the source, double the output. And that wasn't terribly interesting to begin with. Aug 27, 2017 at 3:26
• I've downvoted this as, even by my standards, this is far too trivial, solvable with basic subtraction or square rooting, as illustrated by a lot of the solutions so far. Aug 27, 2017 at 8:04
• @BillSteihn You don't understand - this is code golf. The goal is to find the shortest answer, not to be creative. The answer that Shaggy provided is a trivial way of achieving your answer, and will be the shortest way to solve this challenge in most languages. Aug 27, 2017 at 9:20
• As @QwerpDerp said, this is code golf; creativity is, for the most part, not conducive to a healthy byte count. Aug 27, 2017 at 17:09

# Mathematica, 2 bytes

4!


4! returns 24
4!! returns 8

• This one is really cute :)
– lynn
Aug 27, 2017 at 13:21

## Many languages, 4 bytes

16-1


Outputs 15.

16-11


Outputs 5.

This is a CW answer for many languages it works for. Edit to add to the list:

• APL
• bc
• Dyvil
• I
• J
• Japt
• Javascript REPL
• Java REPL
• Julia REPL
• Mathematica
• Python REPL
• R REPL
• Ruby REPL
• Scala REPL
• Swift REPL
• TI-83/84 Basic
• JavaScript (console only). But I'm not sure if it would be valid.
– user72349
Aug 27, 2017 at 2:12
• @ThePirateBay I think REPL answers are valid. This should work for Python too, in a REPL environment, right? Aug 27, 2017 at 2:51
• @IsmaelMiguel Yes, though they count as separate languages. i added both.
– xnor
Aug 27, 2017 at 2:55
• I suspect your list is going to get quite long for this one! Works in Japt (although you could replace 16 with a constant to save a byte). Aug 27, 2017 at 6:50
• Sage as well. :) Aug 27, 2017 at 14:46

# Lost, 52, 18 bytes

\(@>>>
\>>%?
\(13$ Try it online! \(@>>> \>>%? \(13$$ Try it online! ## Explanation Lost is a language in which the start location and direction of the pointer are entirely random. Thus making a deterministic program can be tough. The code we want to execute is either 13(@ or 13$$(@. • 31 pushes 3 and 1 to the stack • $ will swap them
• $ will swap them back if present • ( will pop the top element • @ will halt and output We want to insert the $ at the end so we have to split this

\(@
v
\31\$


The rest of this is a careful orchestration to make sure that every possible pointer executes this code and only this code.

# Operation Flashpoint scripting language, 19 bytes

a="3";aa="1";hint a


Outputs:

a="3";aa="1";hint aa


Outputs:

• Wow, just wow :D Anyway, can't you just hint a,aa? Aug 27, 2017 at 9:54
• @KeyWeeUsr You mean to output both at the same time? hint format["%1\n%2", a, aa] would do that (or hint (a+"\n"+aa) because they are strings), but I think outputting them separately illustrates the solution better here. Aug 27, 2017 at 17:10
• The screenshots are always entertaining now, you sniping a tank, eh? Nov 7, 2017 at 22:57
• @MagicOctopusUrn Just observing it and the surroundings with my binoculars. It's way out of range for any anti-tank weapons I'd might be carrying, so I need to get closer, but first I must check that there's no enemy infantry around preventing me from doing so. Nov 7, 2017 at 23:05
• @Steadybox obviously you'd recommend this game, eh? Is it a steam game? Nov 7, 2017 at 23:12

# Jelly, 2 bytes

3ȷ


Try it online!

Outputs 3000. 3ȷ is a numeric literal for 3000.

3ȷȷ outputs 1000: 3ȷ is 3000, which is thrown away and replaced by ȷ, 1000.

This is the only two-byte solution, and it is optimal; I found it by trying every possible program.

# Actually, 2 bytes

5¬


Try it online!

Repeating the last character: 5¬¬.

Explanation:

5¬
5   push 5
¬  subtract 2


Adding another ¬ causes 2 to be subtracted from 3, yielding 1.

• Paradoc version: 5«, 5«« I hope you find this symbol choice more mnemonic — it was supposed to be one of its comparative strengths :) Aug 27, 2017 at 5:44

# Python 2, 9 bytes

print 3&3


Try it online! Prints 3.

print 3&33


Try it online! Prints 1.

• Also works with 3&7, 6&6, 7&3, 7&6, or 8^1 Aug 27, 2017 at 1:14
• Shave off 6 bytes by using REPL Aug 27, 2017 at 8:37

# Pyke, 2 bytes

This prints 3 and 6ee prints 1.

6e


Try it here!

6ee


Try it here!

6  - Push 6.
e - Floor halve.
- Print Implicitly.


# How?

Not much to explain. The whole point of this solution is that:

$\inline&space;\text{floor}(\frac{6}{2})=3\text{,}$ $\inline&space;\text{floor}(\frac{\text{floor}(\frac{6}{2})}{2})=1$

# CJam, 4 bytes

2_5+


Outputs 27. Try it online!

2_5++


Outputs 9. Try it online!

gcd 3 21


Outputs 3, and gcd 3 211 outputs 1.

# Jelly, 3 bytes

81½


Try it online!

Outputs 9.

81½½


Try it online!

Outputs 3.

• Is ½ really square root? I can't figure which is worse, the ½ or Actually's ¬ Aug 27, 2017 at 8:37

# 05AB1E, 3 bytes

3Xr


Outputs 3.

Try it online!

3Xrr


Outputs 1.

Try it online!

• 5Í, maybe? :P Aug 27, 2017 at 13:54
• тg too ;)...? Feb 8, 2018 at 16:35

# Cubix, 6 bytes

Works by changing the path based on cubes with different edge sizes. None of that tricky math stuff. The starting numbers could be also 1 3 or 2 6

39O@W@


Cubified

  3
9 O @ W
@


Try it online!

Only executes 9O@ which is Push 9, Output as number, Halt.

39O@W@


Cubified

    3 9
O @
W @ @ . . . . .
. . . . . . . .
. .
. .


This now executes W3O@, which is Left shift, Push 3, Output as number, Halt.

Try it online!

# Mathematica, 13 bytes

PrimeOmega@27


Not the shortest solution but y'know...

# Polyglot, 05AB1E / 2sable, 3 bytes

This one prints 9. 81tt prints 3.

81t

81tt


# Befunge-98, 6 bytes

<q%5b'


Try it online!

Outputs via exit code.

Explanation: On program start the IP is immediately sent leftwards, so it wraps to the right end and executes commands from right to left. So, in this program, it encounters 'b5%, which pushes 98, the value of the character b, and then computes the remainder of 98 when divided by 5, which is 3. Finally, with q, it quits with this exit code.

With the last character doubled, it encounters ''b5%, which pushes the value of the character ' but then immediately pushes b, which is 11. It then computes the remainder of 11 when divided by 5, which is 1, and quits with this exit code.

• "It then computes the remainder of 12 when divided by 5, which is 1, and quits with this exit code." - I think you mean 11...
– Luke
Aug 27, 2017 at 18:03
• You're right, fixed Aug 27, 2017 at 18:04

# C, 60 45 bytes

Thanks to @nwellnhof for saving 15 bytes!

#define AA"5");}
#define A"1"AA
main(){puts(A


Outputs 15

#define AA"5");}
#define A"1"AA
main(){puts(AA


Outputs 5

• #define AA"5");} #define A"1"AA main(){puts(A Aug 27, 2017 at 18:50
• @nwellnhof Thanks! Aug 27, 2017 at 20:57

# Pyth, 4 bytes

This prints 9. x8 11 prints 3.

x8 1


Try it online!

x8 11


Try it online!

# How?

x8 1  - Full program.

x     - Bitwise XOR.
8 1  - Of 8 and 1.
- Implicitly print.


# Befunge-98 (PyFunge), 5 bytes

[q/3g


Try it online!

Outputs via exit code.

### Explanation

First, the IP hits the "turn left" instruction ([) twice, which wraps it back around to the back of the code, going right.

The "get" instruction (g) takes the first 2 values and pushes the ASCII value of the character at that x and y position. The first time it is executed, there are only zeros on the stack, meaning we get the value 91. If we don't double the g, we divide 91 by 3, with integer division, truncating it to 30, which is returned.

If we do duplicate the g, it gets the ASCII value at (0, 91), which isn't anywhere near the code. Because the grid is initialized to be filled with spaces, this returns the value 32. if we integer divide by 3, we get 10, one third of 30.

# Python 2, 16 bytes

a=3;aa=1;print a


outputs 3

a=3;aa=1;print aa


outputs 1

# V, 5 bytes

é52ñ


Try it online!

Outputs 3

é52ñ


Try it online!

Outputs 1

# Ly, 6 bytes

3>1<<>


Try it online!

Outputs 3.

With the second character duplicated:

3>1<<>>


Try it online!

Outputs 1.

# Recursiva, 5 bytes

+16-1


Try it online!

• Ripped off from Many languages solution, only a byte more since Recursiva is prefix and - sign and subtract operator are the same. This is actually adding 16 and -1.

# Recursiva, 10 bytes

Y_+B5A3IH1


Try it online!

# Jelly, 5 bytes

This one outputs 3. By doubling the last character, you get 1.

HḞ
6Ç


Try it online!

HḞ
6ÇÇ


Try it online!

# Japt, 3 bytes

Still on the hunt for a 2 byte solution.

#Q is 81 and ¬ is square root, which gives 9. Adding another ¬ at the end gives 3

#Q¬


Try it

#Q¬¬


Try it

# ><>, 6 bytes

",n;c!


Try it online!

",n;c!!


Try it online!

### Explanation

",n;c!  : Put each character onto the stack;
[110, 59, 99, 33]
,n;    : Divide the top two stack items, print as a number and end.
99/33 = 3


",n;c!! : Put each chat onto the stack;
[110, 59, 99, 33, 33]
,n;    : Divide the top two stack items, print as a number and end.
99/33 = 3

• This ports to Runic and doesn't feel worth posting as its own answer. Feb 9, 2019 at 23:28

# Pyt, 2 bytes

9₃


Returns 9/3

Try it online!

9₃₃


Returns (9/3)/3

Try it online!

Alternatively, also 2 bytes:

6₂


This works due to Python 2's integer division

# Pyth, 5 bytes

-16 1


Try it online!

# Charcoal, 6 bytes

This one prints 15. The other version prints 5.

Ｉ⁻¹⁶¦¹


Try it online!

Ｉ⁻¹⁶¦¹¹


Try it online!

# Neim, 2 bytes

ηᚠ


Outputs 3. Doubled, outputs 1.

Try it online!

Doubled