Skip to content

Instantly share code, notes, and snippets.

@cschlisner
Created April 2, 2014 23:31
Show Gist options
  • Save cschlisner/9945447 to your computer and use it in GitHub Desktop.
Save cschlisner/9945447 to your computer and use it in GitHub Desktop.
class q1 {
public static void main(String args[]){
int n = Integer.valueOf(args[0]);
int upperBound5 = ((n%5==0)?(n/5)-1:n/5), upperBound3 = ((n%3==0)?(n/3)-1:n/3), total=0;
for (int i=1; i<=((upperBound5>upperBound3)?upperBound5:upperBound3); ++i)
total += (((i*((upperBound5>=i)?5:0)))+(i*((upperBound3>=i)?3:0)));
System.out.println(upperBound5+" "+upperBound3+" "+total);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment