Test cases:
Test cases | Expected | Result |
---|---|---|
isDivisibleBy7(17) | false | OK |
isDivisibleBy7(77) | true | OK |
isDivisibleBy7(12) | false | OK |
Java solution:
public class Program3 {
public static void main(String[] args) {
Program3.isDivisibleBy7(17);
Program3.isDivisibleBy7(77);
Program3.isDivisibleBy7(12);
}
public static boolean isDivisibleBy7(int num){
if (num % 7 == 0) {
return true;
}
return false;
}
}
Javascript solution:
const isDivisibleBy7 = (num) => {
if (num % 7 === 0) {
return true;
}
return false;
}
console.log(isDivisibleBy7(17)); //false
console.log(isDivisibleBy7(77)); //true
console.log(isDivisibleBy7(12)); //false