Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TQC+ JAVA
import java.util.*;
class JPA03 {
Scanner input = new Scanner(System.in);
public static void main(String argv[]) {
int sum = 0;
int num = input.nextInt();
for(int index=1;index<=num;index++) {
if((index % 3 == 0 || index % 5 == 0) && index % 7 != 0) {
sum += index;
}
}
System.out.println("Answer: " + sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.