Find the sum of numbers between 100 and 200 those are divisible by 7.
[sourcecode language="java"]
package myrnd;
public class SpecificSum {
public static void main(String[] args) {
int result = 0;
for (int i = 100; i < 200; i++) {
if (i % 7 == 0) {
result += i;
}
}
System.out.println("Sum:" + result);
}
}
[/sourcecode]
No comments:
Post a Comment