Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 24, 2017 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peter279k/68279a310b18221e45e53dd7a07bf116 to your computer and use it in GitHub Desktop.
Save peter279k/68279a310b18221e45e53dd7a07bf116 to your computer and use it in GitHub Desktop.
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