WeixiangYan/CodeTransOcean huggingface dataset:
Task: Frobenius numbers

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 10000


unsigned int sieve(unsigned int n, unsigned int **list) {
    unsigned char *sieve = calloc(n+1, 1);
    unsigned int i, j, max = 0;
    for (i = 2; i*i <= n; i++)
        if (!sieve[i])
            for (j = i+i; j <= n; j += i)
                sieve[j] = 1;
    for (i = 2; i <= n; i++) max += !sieve[i];
    *list = malloc(max * sizeof(unsigned int));
    for (i = 0, j = 2; j <= n; j++)
        if (!sieve[j]) (*list)[i++] = j;
    free(sieve);
    return i;
}


unsigned int frob(unsigned const int *primes, unsigned int n) {
    return primes[n] * primes[n+1] - primes[n] - primes[n+1];
}

int main() {
    
    unsigned int *primes;
    unsigned int amount = sieve(sqrt(LIMIT)+1, &primes);
    unsigned int i;
    
    for (i=0; i<amount-1; i++) printf("%d\n", frob(primes, i));
    free(primes);
    
    return 0;
}



C#: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}
Task: Frobenius numbers

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 10000


unsigned int sieve(unsigned int n, unsigned int **list) {
    unsigned char *sieve = calloc(n+1, 1);
    unsigned int i, j, max = 0;
    for (i = 2; i*i <= n; i++)
        if (!sieve[i])
            for (j = i+i; j <= n; j += i)
                sieve[j] = 1;
    for (i = 2; i <= n; i++) max += !sieve[i];
    *list = malloc(max * sizeof(unsigned int));
    for (i = 0, j = 2; j <= n; j++)
        if (!sieve[j]) (*list)[i++] = j;
    free(sieve);
    return i;
}


unsigned int frob(unsigned const int *primes, unsigned int n) {
    return primes[n] * primes[n+1] - primes[n] - primes[n+1];
}

int main() {
    
    unsigned int *primes;
    unsigned int amount = sieve(sqrt(LIMIT)+1, &primes);
    unsigned int i;
    
    for (i=0; i<amount-1; i++) printf("%d\n", frob(primes, i));
    free(primes);
    
    return 0;
}


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}
Task: Frobenius numbers

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 10000


unsigned int sieve(unsigned int n, unsigned int **list) {
    unsigned char *sieve = calloc(n+1, 1);
    unsigned int i, j, max = 0;
    for (i = 2; i*i <= n; i++)
        if (!sieve[i])
            for (j = i+i; j <= n; j += i)
                sieve[j] = 1;
    for (i = 2; i <= n; i++) max += !sieve[i];
    *list = malloc(max * sizeof(unsigned int));
    for (i = 0, j = 2; j <= n; j++)
        if (!sieve[j]) (*list)[i++] = j;
    free(sieve);
    return i;
}


unsigned int frob(unsigned const int *primes, unsigned int n) {
    return primes[n] * primes[n+1] - primes[n] - primes[n+1];
}

int main() {
    
    unsigned int *primes;
    unsigned int amount = sieve(sqrt(LIMIT)+1, &primes);
    unsigned int i;
    
    for (i=0; i<amount-1; i++) printf("%d\n", frob(primes, i));
    free(primes);
    
    return 0;
}





Java: public class Frobenius {
    public static void main(String[] args) {
        final int limit = 1000000;
        System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit);
        PrimeGenerator primeGen = new PrimeGenerator(1000, 100000);
        int prime1 = primeGen.nextPrime();
        for (int count = 1; ; ++count) {
            int prime2 = primeGen.nextPrime();
            int frobenius = prime1 * prime2 - prime1 - prime2;
            if (frobenius >= limit)
                break;
            System.out.printf("%6d%c%c", frobenius,
                    isPrime(frobenius) ? '*' : ' ',
                    count % 10 == 0 ? '\n' : ' ');
            prime1 = prime2;
        }
        System.out.println();
    }

    private static boolean isPrime(int n) {
        if (n < 2)
            return false;
        if (n % 2 == 0)
            return n == 2;
        if (n % 3 == 0)
            return n == 3;
        for (int p = 5; p * p <= n; p += 4) {
            if (n % p == 0)
                return false;
            p += 2;
            if (n % p == 0)
                return false;
        }
        return true;
    }
}
Task: Frobenius numbers

C: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 10000


unsigned int sieve(unsigned int n, unsigned int **list) {
    unsigned char *sieve = calloc(n+1, 1);
    unsigned int i, j, max = 0;
    for (i = 2; i*i <= n; i++)
        if (!sieve[i])
            for (j = i+i; j <= n; j += i)
                sieve[j] = 1;
    for (i = 2; i <= n; i++) max += !sieve[i];
    *list = malloc(max * sizeof(unsigned int));
    for (i = 0, j = 2; j <= n; j++)
        if (!sieve[j]) (*list)[i++] = j;
    free(sieve);
    return i;
}


unsigned int frob(unsigned const int *primes, unsigned int n) {
    return primes[n] * primes[n+1] - primes[n] - primes[n+1];
}

int main() {
    
    unsigned int *primes;
    unsigned int amount = sieve(sqrt(LIMIT)+1, &primes);
    unsigned int i;
    
    for (i=0; i<amount-1; i++) printf("%d\n", frob(primes, i));
    free(primes);
    
    return 0;
}







Python: 

def isPrime(v):
  if v <= 1:
    return False
  if v < 4:
    return True
  if v % 2 == 0:
    return False
  if v < 9:
    return True
  if v % 3 == 0:
    return False
  else:
    r = round(pow(v,0.5))
    f = 5
    while f <= r:
      if v % f == 0 or v % (f + 2) == 0:
        return False
      f += 6
    return True

pn = 2
n = 0
for i in range(3, 9999, 2):
  if isPrime(i):
    n += 1
    f = (pn * i) - pn - i
    if f > 10000:
      break
    print (n, ' => ', f)
    pn = i
Task: Frobenius numbers


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}


C#: using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;

class Program {

    static bool ispr(int x) { int lim = (int)Sqrt((double)x);
        if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
        for (int d = 5; d <= lim; d += (odd = !odd) ? 2 : 4) {
        if (x % d == 0) return false; } return true; }

    static void Main() {
        int c = 0, d = 0, f, lim = 1000000, l2 = lim / 100; var Frob = PG.Primes((int)Sqrt(lim) + 1).ToArray();
        for (int n = 0, m = 1; m < Frob.Length; n = m++) {
            if ((f = Frob[n] * Frob[m] - Frob[n] - Frob[m]) < l2) d++;
            Write("{0,7:n0}{2} {1}", f , ++c % 10 == 0 ? "\n" : "", ispr(f) ? " " : "*"); }
        Write("\n\nCalculated {0} Frobenius numbers of consecutive primes under {1:n0}, " +
            "of which {2} were under {3:n0}", c, lim, d, l2); } }

class PG { public static IEnumerable<int> Primes(int lim) { 
    var flags = new bool[lim + 1]; int j = 3; yield return 2; 
    for (int d = 8, sq = 9; sq <= lim; j += 2, sq += d += 8)
      if (!flags[j]) { yield return j;
        for (int k = sq, i = j << 1; k <= lim; k += i) flags[k] = true; }
    for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }
Task: Frobenius numbers


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}



Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    primes := rcu.Primes(101)
    var frobenius []int
    for i := 0; i < len(primes)-1; i++ {
        frob := primes[i]*primes[i+1] - primes[i] - primes[i+1]
        if frob >= 10000 {
            break
        }
        frobenius = append(frobenius, frob)
    }
    fmt.Println("Frobenius numbers under 10,000:")
    for i, n := range frobenius {
        fmt.Printf("%5s ", rcu.Commatize(n))
        if (i+1)%9 == 0 {
            fmt.Println()
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", len(frobenius))
}
Task: Frobenius numbers


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}




Java: public class Frobenius {
    public static void main(String[] args) {
        final int limit = 1000000;
        System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit);
        PrimeGenerator primeGen = new PrimeGenerator(1000, 100000);
        int prime1 = primeGen.nextPrime();
        for (int count = 1; ; ++count) {
            int prime2 = primeGen.nextPrime();
            int frobenius = prime1 * prime2 - prime1 - prime2;
            if (frobenius >= limit)
                break;
            System.out.printf("%6d%c%c", frobenius,
                    isPrime(frobenius) ? '*' : ' ',
                    count % 10 == 0 ? '\n' : ' ');
            prime1 = prime2;
        }
        System.out.println();
    }

    private static boolean isPrime(int n) {
        if (n < 2)
            return false;
        if (n % 2 == 0)
            return n == 2;
        if (n % 3 == 0)
            return n == 3;
        for (int p = 5; p * p <= n; p += 4) {
            if (n % p == 0)
                return false;
            p += 2;
            if (n % p == 0)
                return false;
        }
        return true;
    }
}
Task: Frobenius numbers


C++: #include <cstdint>
#include <iomanip>
#include <iostream>
#include <primesieve.hpp>

bool is_prime(uint64_t n) {
    if (n < 2)
        return false;
    if (n % 2 == 0)
        return n == 2;
    if (n % 3 == 0)
        return n == 3;
    for (uint64_t p = 5; p * p <= n; p += 4) {
        if (n % p == 0)
            return false;
        p += 2;
        if (n % p == 0)
            return false;
    }
    return true;
}

int main() {
    const uint64_t limit = 1000000;
    std::cout << "Frobenius numbers less than " << limit
              << " (asterisk marks primes):\n";
    primesieve::iterator it;
    uint64_t prime1 = it.next_prime();
    for (int count = 1;; ++count) {
        uint64_t prime2 = it.next_prime();
        uint64_t frobenius = prime1 * prime2 - prime1 - prime2;
        if (frobenius >= limit)
            break;
        std::cout << std::setw(6) << frobenius
                  << (is_prime(frobenius) ? '*' : ' ')
                  << (count % 10 == 0 ? '\n' : ' ');
        prime1 = prime2;
    }
    std::cout << '\n';
}






Python: 

def isPrime(v):
  if v <= 1:
    return False
  if v < 4:
    return True
  if v % 2 == 0:
    return False
  if v < 9:
    return True
  if v % 3 == 0:
    return False
  else:
    r = round(pow(v,0.5))
    f = 5
    while f <= r:
      if v % f == 0 or v % (f + 2) == 0:
        return False
      f += 6
    return True

pn = 2
n = 0
for i in range(3, 9999, 2):
  if isPrime(i):
    n += 1
    f = (pn * i) - pn - i
    if f > 10000:
      break
    print (n, ' => ', f)
    pn = i
Task: Frobenius numbers



C#: using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;

class Program {

    static bool ispr(int x) { int lim = (int)Sqrt((double)x);
        if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
        for (int d = 5; d <= lim; d += (odd = !odd) ? 2 : 4) {
        if (x % d == 0) return false; } return true; }

    static void Main() {
        int c = 0, d = 0, f, lim = 1000000, l2 = lim / 100; var Frob = PG.Primes((int)Sqrt(lim) + 1).ToArray();
        for (int n = 0, m = 1; m < Frob.Length; n = m++) {
            if ((f = Frob[n] * Frob[m] - Frob[n] - Frob[m]) < l2) d++;
            Write("{0,7:n0}{2} {1}", f , ++c % 10 == 0 ? "\n" : "", ispr(f) ? " " : "*"); }
        Write("\n\nCalculated {0} Frobenius numbers of consecutive primes under {1:n0}, " +
            "of which {2} were under {3:n0}", c, lim, d, l2); } }

class PG { public static IEnumerable<int> Primes(int lim) { 
    var flags = new bool[lim + 1]; int j = 3; yield return 2; 
    for (int d = 8, sq = 9; sq <= lim; j += 2, sq += d += 8)
      if (!flags[j]) { yield return j;
        for (int k = sq, i = j << 1; k <= lim; k += i) flags[k] = true; }
    for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }


Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    primes := rcu.Primes(101)
    var frobenius []int
    for i := 0; i < len(primes)-1; i++ {
        frob := primes[i]*primes[i+1] - primes[i] - primes[i+1]
        if frob >= 10000 {
            break
        }
        frobenius = append(frobenius, frob)
    }
    fmt.Println("Frobenius numbers under 10,000:")
    for i, n := range frobenius {
        fmt.Printf("%5s ", rcu.Commatize(n))
        if (i+1)%9 == 0 {
            fmt.Println()
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", len(frobenius))
}
Task: Frobenius numbers



C#: using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;

class Program {

    static bool ispr(int x) { int lim = (int)Sqrt((double)x);
        if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
        for (int d = 5; d <= lim; d += (odd = !odd) ? 2 : 4) {
        if (x % d == 0) return false; } return true; }

    static void Main() {
        int c = 0, d = 0, f, lim = 1000000, l2 = lim / 100; var Frob = PG.Primes((int)Sqrt(lim) + 1).ToArray();
        for (int n = 0, m = 1; m < Frob.Length; n = m++) {
            if ((f = Frob[n] * Frob[m] - Frob[n] - Frob[m]) < l2) d++;
            Write("{0,7:n0}{2} {1}", f , ++c % 10 == 0 ? "\n" : "", ispr(f) ? " " : "*"); }
        Write("\n\nCalculated {0} Frobenius numbers of consecutive primes under {1:n0}, " +
            "of which {2} were under {3:n0}", c, lim, d, l2); } }

class PG { public static IEnumerable<int> Primes(int lim) { 
    var flags = new bool[lim + 1]; int j = 3; yield return 2; 
    for (int d = 8, sq = 9; sq <= lim; j += 2, sq += d += 8)
      if (!flags[j]) { yield return j;
        for (int k = sq, i = j << 1; k <= lim; k += i) flags[k] = true; }
    for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }



Java: public class Frobenius {
    public static void main(String[] args) {
        final int limit = 1000000;
        System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit);
        PrimeGenerator primeGen = new PrimeGenerator(1000, 100000);
        int prime1 = primeGen.nextPrime();
        for (int count = 1; ; ++count) {
            int prime2 = primeGen.nextPrime();
            int frobenius = prime1 * prime2 - prime1 - prime2;
            if (frobenius >= limit)
                break;
            System.out.printf("%6d%c%c", frobenius,
                    isPrime(frobenius) ? '*' : ' ',
                    count % 10 == 0 ? '\n' : ' ');
            prime1 = prime2;
        }
        System.out.println();
    }

    private static boolean isPrime(int n) {
        if (n < 2)
            return false;
        if (n % 2 == 0)
            return n == 2;
        if (n % 3 == 0)
            return n == 3;
        for (int p = 5; p * p <= n; p += 4) {
            if (n % p == 0)
                return false;
            p += 2;
            if (n % p == 0)
                return false;
        }
        return true;
    }
}
Task: Frobenius numbers



C#: using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;

class Program {

    static bool ispr(int x) { int lim = (int)Sqrt((double)x);
        if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
        for (int d = 5; d <= lim; d += (odd = !odd) ? 2 : 4) {
        if (x % d == 0) return false; } return true; }

    static void Main() {
        int c = 0, d = 0, f, lim = 1000000, l2 = lim / 100; var Frob = PG.Primes((int)Sqrt(lim) + 1).ToArray();
        for (int n = 0, m = 1; m < Frob.Length; n = m++) {
            if ((f = Frob[n] * Frob[m] - Frob[n] - Frob[m]) < l2) d++;
            Write("{0,7:n0}{2} {1}", f , ++c % 10 == 0 ? "\n" : "", ispr(f) ? " " : "*"); }
        Write("\n\nCalculated {0} Frobenius numbers of consecutive primes under {1:n0}, " +
            "of which {2} were under {3:n0}", c, lim, d, l2); } }

class PG { public static IEnumerable<int> Primes(int lim) { 
    var flags = new bool[lim + 1]; int j = 3; yield return 2; 
    for (int d = 8, sq = 9; sq <= lim; j += 2, sq += d += 8)
      if (!flags[j]) { yield return j;
        for (int k = sq, i = j << 1; k <= lim; k += i) flags[k] = true; }
    for (; j <= lim; j += 2) if (!flags[j]) yield return j; } }





Python: 

def isPrime(v):
  if v <= 1:
    return False
  if v < 4:
    return True
  if v % 2 == 0:
    return False
  if v < 9:
    return True
  if v % 3 == 0:
    return False
  else:
    r = round(pow(v,0.5))
    f = 5
    while f <= r:
      if v % f == 0 or v % (f + 2) == 0:
        return False
      f += 6
    return True

pn = 2
n = 0
for i in range(3, 9999, 2):
  if isPrime(i):
    n += 1
    f = (pn * i) - pn - i
    if f > 10000:
      break
    print (n, ' => ', f)
    pn = i
Task: Frobenius numbers





Java: public class Frobenius {
    public static void main(String[] args) {
        final int limit = 1000000;
        System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit);
        PrimeGenerator primeGen = new PrimeGenerator(1000, 100000);
        int prime1 = primeGen.nextPrime();
        for (int count = 1; ; ++count) {
            int prime2 = primeGen.nextPrime();
            int frobenius = prime1 * prime2 - prime1 - prime2;
            if (frobenius >= limit)
                break;
            System.out.printf("%6d%c%c", frobenius,
                    isPrime(frobenius) ? '*' : ' ',
                    count % 10 == 0 ? '\n' : ' ');
            prime1 = prime2;
        }
        System.out.println();
    }

    private static boolean isPrime(int n) {
        if (n < 2)
            return false;
        if (n % 2 == 0)
            return n == 2;
        if (n % 3 == 0)
            return n == 3;
        for (int p = 5; p * p <= n; p += 4) {
            if (n % p == 0)
                return false;
            p += 2;
            if (n % p == 0)
                return false;
        }
        return true;
    }
}



Python: 

def isPrime(v):
  if v <= 1:
    return False
  if v < 4:
    return True
  if v % 2 == 0:
    return False
  if v < 9:
    return True
  if v % 3 == 0:
    return False
  else:
    r = round(pow(v,0.5))
    f = 5
    while f <= r:
      if v % f == 0 or v % (f + 2) == 0:
        return False
      f += 6
    return True

pn = 2
n = 0
for i in range(3, 9999, 2):
  if isPrime(i):
    n += 1
    f = (pn * i) - pn - i
    if f > 10000:
      break
    print (n, ' => ', f)
    pn = i
Task: Frobenius numbers




Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    primes := rcu.Primes(101)
    var frobenius []int
    for i := 0; i < len(primes)-1; i++ {
        frob := primes[i]*primes[i+1] - primes[i] - primes[i+1]
        if frob >= 10000 {
            break
        }
        frobenius = append(frobenius, frob)
    }
    fmt.Println("Frobenius numbers under 10,000:")
    for i, n := range frobenius {
        fmt.Printf("%5s ", rcu.Commatize(n))
        if (i+1)%9 == 0 {
            fmt.Println()
        }
    }
    fmt.Printf("\n\n%d such numbers found.\n", len(frobenius))
}




Python: 

def isPrime(v):
  if v <= 1:
    return False
  if v < 4:
    return True
  if v % 2 == 0:
    return False
  if v < 9:
    return True
  if v % 3 == 0:
    return False
  else:
    r = round(pow(v,0.5))
    f = 5
    while f <= r:
      if v % f == 0 or v % (f + 2) == 0:
        return False
      f += 6
    return True

pn = 2
n = 0
for i in range(3, 9999, 2):
  if isPrime(i):
    n += 1
    f = (pn * i) - pn - i
    if f > 10000:
      break
    print (n, ' => ', f)
    pn = i