Java 判断一个数能否同时被 3 和 5 整除
public class Main { public static void main(String[] args) { int num = 15; // 定义一个整数变量num,赋值为15 if (num % 3 == 0 && num % 5 == 0) { // 判断num能否同时被3和5整除 System.out.println(num + '能同时被3和5整除。'); // 如果能,则输出提示信息 } else { System.out.println(num + '不能同时被3和5整除。'); // 如果不能,则输出提示信息 } } }
// 输出结果为:15能同时被3和5整除。
原文地址: https://www.cveoy.top/t/topic/jZjD 著作权归作者所有。请勿转载和采集!