Advertisement
Guest User

Untitled

a guest
May 1st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const xor64 = function (y) {
  4. y = y >>> 0;
  5. y = y ^ (y << 13);
  6. y = y ^ (y >> 7);
  7. y = y ^ (y << 17);
  8. return y >>> 0;
  9. };
  10.  
  11. const GCD = function(m, n) {
  12. while (n != 0) {
  13. [m, n] = [n, m % n];
  14. }
  15. return m;
  16. }
  17.  
  18. const factorize = function (n) {
  19. const f = function (seed) {
  20. return xor64(seed) % n;
  21. }
  22. let x = 2;
  23. let y = 2;
  24. let d = 1;
  25. while (d == 1) {
  26. x = f(x);
  27. y = f(f(y));
  28. d = GCD(Math.abs(x - y), n);
  29. }
  30. if (d == n) {
  31. return false;
  32. }
  33. return d;
  34. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement