언어/JAVA
java) 5의 배수이면서 7의 배수인 정수를 출력하기
[Nada]
2019. 11. 28. 15:11
문제) 5의 배수이면서 7의 배수인 정수를 출력하고 개수 출력
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public class ContinueBreak {
public static void main(String[] args) {
int count = 0; // 개수를 셀 변수
for(int num=1; num<100; num++) {
if(num%5 !=0 || num%7 !=0)
continue;
count++;
System.out.println(num);
}
System.out.println("count: " + count);
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |