Write a Scala program to check whether a given positive number is a multiple of 3 or a multiple of 7
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
object scala_basic {
def test(n: Int): Boolean =
{
n % 3 == 0 || n % 7 == 0;
}
def main(args: Array[String]): Unit = {
println("Result: " + test(3));
println("Result: " + test(14));
println("Result: " + test(12));
println("Result: " + test(37));
}
}
Sample Output:
Result: true Result: true Result: true Result: false
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة