7
1
The Code
Your program should take an input of n > 2 and output the largest prime less than or equal to n. You can choose how the number is input (standard input, read from a file, etc). For example:
Input Output
3 3
9 7
28 23
486 479
Simple enough. And if a program passes all of the test cases it's gonna work fine, right?
The Underhanded
Too bad your program will only pass the test cases. It should work properly for 3, 9, 28, and 486 and no other numbers. Since this is an underhanded challenge, this shouldn't be obvious to a person glancing over the code.
Bonus points if the program still outputs something and if the output isn't obviously composite (getting 555 for 556 would be a little suspicious). This is a popularity contest, so the most popular answer wins. Which means the bonus points are completely meaningless. Oh well!
3
I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469
– cat – 2016-04-18T15:23:34.430@PeterTaylor whoops! Thought I had it "as less than or equal to." Edited that in. Thanks for the catch! – Hovercouch – 2014-01-24T06:06:30.527