Determine a general formula (in terms of n) for the sum of the first n positive integers that are not divisible by 5.

Actually, in my first post, my formula, while correct, does not 100% match my description.

What I said was Sum = (n+s)(n+s+1)/2 - 5s(s+1)/2, where s is the number of numbers that need to be skipped to get n that are not multiples of 5.

And then I said s = floor(n/4). This works, but the formula also works if s = floor((n-1)/4), and it is the 2nd s which better matches my description.

Take the case where n = 12.

If s = 2, then (n+s)(n+s+1)/2 - 5s(s+1)/2 = 105 - 15 = 90

If s = 3, then (n+s)(n+s+1)/2 - 5s(s+1)/2 = 120 - 30 = 90

The 1st value of s corresponds to summing up all numbers from 1 to 14 and then subtracting out 5 and 10.

The 2nd value of s corresponds to summin up all numbers from 1 to 15 and then subtracting out 5 and 10 and 15.

I leave it to tomarken to say which is more elegant. I can't tell.