3
Objective: Print all multiples of 32 from 0 to an arbitrary number n.
Rules:
One argument will be given: a single integer from 0 to 231 - 1. This will be
n
here on out.The first iteration must be 0, and the last iteration must be
n
. 0 is to be counted as a multiple of 32.Each time a multiple is encountered, the multiple itself must be printed with no leading whitespace, and then it must be immediately followed by a newline (CR, CRLF, and LF are all acceptable as long as they are consistent.
A bug must be introduced such that a minimum of
n+1 floor 32
cases are incorrectly printed/omitted (in the average case).- Perfection is allowed for
n
less than or equal to 32.
- Perfection is allowed for
Your source code must be in pure ASCII. Exceptions only include APL and others that use non-ASCII operators.
This is an underhanded contest. The best code is clear, concise, obvious, and wrong.
Example in C++ (except for clear bug):
// This conforms to the rules, but is a bad entry.
#include <iostream>
#include <cstdlib>
#include <cstdint>
int main(int argc, char* argv[]) {
int32_t max = (int32_t) atol(argv[1]);
int32_t i = 0;
while (i != max) {
if (!(i % 32) && !((int) (4 * random()) / 4)) {
cout << i << endl;
}
i++;
}
return 0;
}
Most popular answer wins, so make it good!
Does printing nothing work? I have an idea, but I'm not sure if that would omit more numbers than the maximum. – KSFT – 2015-01-16T16:34:12.890
@KSFT Actually, since it is a popularity contest, I'm going to modify that rule. – Isiah Meadows – 2015-01-20T14:50:25.767
Why do you prohibit certain characters in the program source? – FUZxxl – 2015-02-04T09:19:51.007
I'll clarify it as ASCII. It's poorly worded – Isiah Meadows – 2015-02-04T09:20:49.763
4
I'm voting to close this question as off-topic because it's an [underhanded] challenge, which was on-topic a year ago, but is now off-topic by community consensus.
– James – 2016-04-23T20:22:35.650"it must match the following regex" -- is multiline mode on? – John Dvorak – 2014-08-15T12:41:25.317
@JanDvorak It matches the whole, not per line. I forget which is multiline. – Isiah Meadows – 2014-08-15T12:41:49.290
floored division is normally denoted by
div
. – John Dvorak – 2014-08-15T12:43:55.5531Is the program supposed to find multiples of 32 or 42? The title says 42, but you said 0 is to be counted as a multiple of 32. – Cameron – 2014-08-16T16:23:32.687
@Cameron Fixed. – Isiah Meadows – 2014-08-17T06:40:16.290
Well the title still says 32 while in the objective it is state as 42, so what now? – flawr – 2014-08-17T07:52:07.040
6I really shouldn't program. – Soham Chowdhury – 2014-09-05T02:52:07.080