I got bored and came up with two methods
#1
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


you are creative, these can be helpful.

Finds if number is odd -

Code:
def odd?(number)
     loop do
          if number == 0
               return false
          elsif number == 1
               return true
          end
          number -= 2
     end
end

Finds if one number is divisable by another -

Code:
def divisable?(dividend,devisor)
     a = 0
     b = dividend.dup
     loop do
          if (devisor * a) > dividend
               return false
          elsif b == 0
               return true
          end
          b -= devisor
          a += 1
     end
end


Don't flame me for being the simple minded guy I am.
}




Users browsing this thread: 1 Guest(s)