Advertisement
Sammy24

Untitled

Apr 7th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. void nr_div_imp(int n, int &div)
  2. {
  3. div = 1;
  4.  
  5. int d = 3;
  6.  
  7. while(n % 2 == 0)
  8. {
  9. n /= 2;
  10. }
  11.  
  12. while(n > 1)
  13. {
  14. int p = 0;
  15.  
  16. while(n % d == 0)
  17. {
  18. p++;
  19. n /= d;
  20. }
  21.  
  22. if(p)
  23. {
  24. div *= (p + 1);
  25. }
  26.  
  27. if(d * d <= n)
  28. {
  29. d += 2;
  30. }
  31. else
  32. {
  33. d = n;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement