in PHP integers...

Discussion in 'Software' started by man_im_bored, Jan 26, 2004.

  1. man_im_bored

    man_im_bored Private E-2

    Is there a function which returns something to say if a number is divisible by two / even or odd?!?!?]]

    like:

    function foo($number)
    {
    if (number_divisble_by_two($number))
    {
    //stuff
    }
    else
    {
    //different stuff
    }
    }

    or

    function fooVersion2point0($number)
    {
    if (even_number($number))
    {
    //stuff
    }
    else //number is odd
    {
    //different stuff
    }
    }
     
    Last edited: Jan 26, 2004
  2. man_im_bored

    man_im_bored Private E-2

    Solution:

    (I've figured it out, so I'm posting it for the benefit of otheres...)

    function oddoreven($number)
    {
    if ($number % 2 == 1) {
    return "the number is odd";
    }
    else
    { return "the number is even";}
    }

    % = a mod
     
  3. Kodo

    Kodo SNATCHSQUATCH

    try the mod function.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds