求1到1000之间同时能被3、5、7整除的数

求1到1000之间同时能被3、5、7整除的数

即同时成立 所以要用与运算&&

 1 public class ZhengChu
 2 {
 3     public static void main(String[] args)
 4     {
 5         for (int i=0;i<=1000 ;i++ )
 6         {
 7             if (i%3==0 && i%5==0 && i%7==0)
 8             {
 9                 System.out.println("能同时被3,5,7整除数为"+i);
10             }        
11         }
12     }
13 }

 

原文地址:https://www.cnblogs.com/coolso/p/5507001.html