class Main {
public static void main
(String[] args
) {
int N = 1000;
int result = sum(3, N-1) + sum(5, N-1) - sum(15, N-1);
}
public static int sum(int n, int N) {
return n * (N/n) * (N/n + 1)/2;
}
}
Y2xhc3MgTWFpbiB7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAKICAgIGludCBOID0gMTAwMDsKICAgIGludCByZXN1bHQgPSBzdW0oMywgTi0xKSArIHN1bSg1LCBOLTEpIC0gc3VtKDE1LCBOLTEpOwogICAgCiAgICBTeXN0ZW0ub3V0LnByaW50bG4ocmVzdWx0KTsKICB9CiAgCiAgcHVibGljIHN0YXRpYyBpbnQgc3VtKGludCBuLCBpbnQgTikgewogICAgICByZXR1cm4gbiAqIChOL24pICogKE4vbiArIDEpLzI7CiAgfQp9