12
1
Write a program which determines if a given number is prime.
The catch: No digits or arithmetical operators. This means:
- No digits from
0
to9
, anywhere in the program, and whatever the meaning - No using any built-in operators for addition (and incrementing), subtraction (and decrementing), multiplication, division, exponentiation, or modulus, anywhere in the program
- This includes symbols like
+
and functions likenum.add()
- All other operations are permitted
- You may define your own functions for the forbidden operations
- You may use symbols like
-
when they mean things other than the forbidden operations
Shortest code wins - any language permitted.
Example solution
An ungolfed solution in Java can be found here.
It would be greatly appreciated if someone would explain the downvotes. – Ypnypn – 2014-04-07T20:47:35.310
4Probably because this is impossible? (Without abusing built-in prime functions, that is.) – Doorknob – 2014-04-07T20:48:16.763
2
Even if not impossible, it is so exclusive of the established techniques for prime detection to be kind of silly ... Feel free to post to Sandbox first to get a feel for how things will turn out before you post.
– ProgrammerDan – 2014-04-07T20:51:11.5271@ProgrammerDan I added a solution using a typical prime-detection method. – Ypnypn – 2014-04-07T21:35:49.540
2
Quite similar to Is it a prime? w/o math?
– daniero – 2014-04-08T00:19:01.757@Ypnypn you should submit your solution as an answer :). – ProgrammerDan – 2014-04-08T00:31:37.790
1In light of algorithmshark's solution; Should point two be updated to prohibit built in primality tests? – Taemyr – 2014-04-08T08:26:38.210
1Any constraints on performance or size of the primes? i.e. does it matter if the program only supports 31 bit primes or has exponential runtime? – CodesInChaos – 2014-04-08T10:41:39.683
it is no sense because even if in any programming language it is not used arithmetic, basically any computer will use arithmetic to make any "for" of "if". – albanx – 2014-04-08T12:05:36.630
Since we may not use any numbers, are we allowed to use length functions (like ''.length, 'a'.length, 'aa'.length,'aaa'.length for 0 up to 3, for example)? – Nzall – 2014-04-08T12:12:18.100
@Nate yes; that's okay. – Ypnypn – 2014-04-08T13:19:39.943
Does the increment operator also count as addition? – celtschk – 2014-04-08T21:24:08.383