Leandro Vieira Pinho´s Blog

Just another WordPress weblog

É ímpar ou par? Confira facilmente usando o PHP

June 1st, 2007. Published under php. 3 Comments.

Utilizando o seguinte código:

$status = (1 & $number) ? 'Ímpar' : 'Par';

Verificamos se o número informado é ímpar ou par, simples ou não?

Leia o original Odd and Even Numbers

3 Comments

Andre Metzen  on June 8th, 2007

Interessante, diferente, mas não acho muito legivel. Prefiro o bom e velho
$status($number % 2 ==0) ? “Par” : “Impar”;

hehhee
abraços!

Fábio  on November 3rd, 2007

Só que este é mais lento André! Comparando os Bits o processo é bem mais rápido!

juicynowater  on July 26th, 2008

black site woman minor ugly sun glass greed

Leave a Comment