Sum of first n natural numbers = n(n+1)/2
Thus sum of first 100 natural numbers = 100(100+1)/2 = 50(101) = 5050
Now ,
Numbers which are divisible by 5 form an AP with common difference 5 and first term 5 and last term 100
Thus if total numbers of terms are n then using AP formula we get
an = a + (n - 1)d
⇒ 100 = 5 + (n-1)5
⇒ (n-1) 5 = 95
⇒ n = 20
Thus sum of all these numbers under 100 which are divisible by 5 is : (n/2) ( a + an)
= (20/2) (5 + 100) = 10(105) = 1050
Thus sum all numbers under 100 which are not divisible by 5 = 5050 - 1050 = 4000