This question already has an answer here:
- I double the source, you double the output! 130 answers
When Steve Jobs launched the iPhone 3G, the slogan said
Twice as fast, half the price
I changed the word fast to long to better represent this challenge.
Write a program that outputs a non-zero, even integer. If the source code is doubled, the value of the output must be cut off by half.
To double the source in a Unix shell (with Core Utilites):
cat source.txt source.txt > doubled-source.txt
Rules & Requirements
Now the requirement has changed and the task has been even more challenging!
- You must build a full program.
- The initial source is no longer required to be at least 1 byte long. An empty program qualifies as long as the output is correct.
- Both the integers must be in base 10 (outputting them in any other base or with scientific notation is forbidden), and must not be zero. The integer is no longer required to be positive, so if you like a negative number, it's OK.
- Your program must not take input (or have an unused, empty input) and must not throw any error (compiler warnings are not considered errors). Exit code must be zero.
- Outputting the integers with trailing / leading spaces / newlines is allowed, as long as only one integer is output.
- You can't assume a newline between copies of your source. If you need one, clarify it. See the Unix shell command above.
- Standard loopholes are forbidden.
Because this is a code-golf, the shortest (original, undoubled) code in each language wins!
Please give description / explanation to your code if possible.