Skip to main content
3 of 5
edited tags
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169

Determine if a number is prime without using arithmetic

Write a program which determines if a given number is prime.

The catch: No digits or arithmetical operators. This means:

  1. No digits from 0 to 9, anywhere in the program, and whatever the meaning
  2. No using any built-in operators for addition, subtraction, multiplication, division, exponentiation, or modulus, anywhere in the program
  3. This includes symbols like + and functions like num.add()
  4. All other operations are permitted
  5. You may define your own functions for the forbidden operations
  6. 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.

Ypnypn
  • 10.9k
  • 2
  • 31
  • 80