Testing divisibility of Integer by 13 and 7

Problem- max number which is divisible by 13 and 7 between 0-100.

i am trying to write a code in Haskell for checking divisibility for 13 and 7. I am able to write for 13 but not able to check for 7 in the same code.

lard :: (Integral a) => a  
lard = head ( filter p[100,99..]) 
    where p x   = x `mod` 13 == 0 

Answers


You can use && to check for both conditions. The overall evaluation is true only if both the operands are true. This operator exists for many (C-like) languages

Like:

lard :: (Integral a) => a  
lard = head ( filter p[100,99..]) 
    where p x   = (x `mod` 13 == 0) && (x `mod` 7 == 0)

Warning: There might be better ways of doing this. I just stepped into the world of Haskell. :)


module Division where divisibility :: [Int] -> [String] divisibility (x:xs) = map show([if xmod13 == 0 && xmod7 == 0 then "divideby13and7" else if xmod13 == 0 then "divideby13" else if xmod7 == 0 then "divideby7" else show(x)| x<-x:xs]


Need Your Help

Is there a stopwatch in Java?

java stopwatch

Is there a stopwatch in Java? On google I only find code of stopwatches which don't work - they always return 0 milliseconds.