When k is a power of 2 , ⌈log√2k⌉−⌊log√2k⌋ = 0
When k is not a power of 2 , ⌈log√2k⌉−⌊log√2k⌋ = 1
So N is the sum of all numbers which are not powers of 2 in the interval [1, 1000]
N=1000∑k=1k−9∑n=02n N=1000∑k=1k−(1+2+4+8+16+32+64+128+256+512) N=1000∑k=1k−1023 N=(1000(1000+1)2)−1023 N=500500−1023 N=499477
It first says approximately 500497, then it comes back and says 499477