# Is it a completely even number?

A completely even number is a positive even integer whose divisors (not including 1) are all even.

Some completely even numbers are 2 (divisors: 2, 1), 4 (divisors: 4, 2, 1), 16 (divisors: 16, 8, 4, 2, 1), and 128 (divisors: 128, 64, 32, 16, 8, 4, 2, 1).

Some non-completely even numbers are 10 (divisors: 10, 5, 2, 1), 12 (divisors: 12, 6, 4, 3, 2, 1), 14 (divisors: 14, 7, 2, 1), and 18 (divisors: 18, 9, 6, 3, 2, 1). 1 is not completely even, and odd numbers are obviously not completely even. 0 is not completely even but you do not need to handle this.

Your challenge is to take a positive integer as input and output a truthy value if it is completely even and a falsy value if it is not. These outputs do not need to be consistent.

Input may be taken via any allowed method, and output may be given via any allowed method.

The shortest code in bytes wins!

• Related – H.PWiz Sep 12 '17 at 16:14
• This is powers of 2 (credit to El'endia Starman in chat for pointing it out) – Skidsdev Sep 12 '17 at 16:22
• – Leaky Nun Sep 12 '17 at 16:23
• @Xcali that one is closed, and this one doesn't have the restricted-source – Stephen Sep 13 '17 at 14:04
• @Dennis, the question contradicts itself. By the definition given in the first paragraph, 1 is completely even, because its divisors except 1 form an empty set and so are trivially all even. – Peter Taylor Sep 14 '17 at 15:30

# JavaScript (Node.js), 12 bytes

n=>(n^n-1)>n


Try it online!

# PHP, 22+1 bytes

<?=($n=$argn)^$n-1>$n;


Run as pipe with -rF. Prints 1 for truthy, empty output for falsy.

hmm ... looks like a port from Dennis´ answer.

### C, 31 bytes

f(x){return !(x&(x-1))&&!(x-1)}


These are the powers of 2, except 1, and thus binary arithmetics solves the problem.

• All submissions must be either full programs or functions. In particular, assuming that the input is stored in a certain variable is not allowed. Also, this approach fails when x = 1, which is a power of two but not.completely even. – Dennis Sep 14 '17 at 0:12
• @Dennis 1) Ok, I did, bit now I lost a lot of bytes. 2) The task still only describes the powers of 2, except 1. 3) What it with the languages on which no functions and procedures exist? 4) If you accept functions and programs, why you don't accept expressions? An expression in C is an independently calculatable execution fragment, just as the programs and the functions. | I am so sad, my solution is already a dirty one, it lacks already the katra. – peterh - Reinstate Monica Sep 14 '17 at 17:46