Advertisement
rimus_cx

Golbach solution

Jan 27th, 2022
1,011
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getPrimeTerms(10000000);
  2.  
  3. function getPrimeTerms(num) {
  4.   for (let i = num / 2; i < num / 2 + num / 20; i++) {
  5.     let a = i;
  6.     let b = num - i;
  7.     if (isPrime(a) && isPrime(b)) {
  8.       console.log(a + ' ' + b);
  9.       break;
  10.     }
  11.   }
  12. }
  13.  
  14. function isPrime(num) {
  15.   for (let i = 2; i < num; i++) {
  16.     if (num % i === 0) return false;
  17.   }
  18.   return num > 1;
  19. }
  20.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement