Guest User

Untitled

a guest
Jun 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4. public static void main(String args[]) {
  5. Scanner sc = new Scanner(System.in);
  6. while (sc.hasNext()) {
  7. long N = sc.nextLong();
  8. if (N == 0)
  9. break;
  10.  
  11. long sum = 0;
  12. long ans = 0, times, R, L = 1;
  13. long count = 0;
  14.  
  15. while (L <= N) {
  16. times = N / L;
  17. R = N / times;
  18. ans += times * ((L + R) * (R - L + 1) / 2);
  19. L = R + 1;
  20. count++;
  21. }
  22. System.out.println(ans - 1);
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment