`

求从10到100中能被3或5整除的数的和

阅读更多
package test;

public class AddTest {
	public static void main(String args[])
	{
		int sum=0; //求和
		
		for(int i=10; i<=100; i++)//循环
		{
			if(i%3==0 || i%5==0) //判断
			{
				sum=sum+1;
			}
		}
		
		
		
		System.out.println(sum);
	}

}

//求从10到100中能被3或5整除的数的和

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics