• + 1 comment

    it would be slightly more efficient, though, to do for(... i < sqrt ...) and if (sqrt*sqrt==n) sum += sqrt; in the end.