# Tag Info

## Hot answers tagged number-theory

5

Take a look at IntegerPartitions, although it relies on brute-force enumeration that is unlikely to scale well. f1[n_] := IntegerPartitions[n, {2}, Prime @ Range @ PrimePi @ n, 1] f2[n_] := Length @ IntegerPartitions[n, {2}, Prime @ Range @ PrimePi @ n] Test: f1[3412] {{3407, 5}} f2[3412] 43

4

The sequence $f[k]$ you are looking for is Sloane's A038664. There is Mathematica code given there by Harvey P. Dale. With[{d=Differences[Prime[Range[50000]]]}, Flatten[Table[Position[d, 2n, 1, 1], {n, 50}]]] which returns {2,4,9,24,34,46,30,...}.

3

Given that the 8th prime is less than 20 (Prime[8] = 19), then the product of all primes up to and including that one is: Times @@ Prime[Range[8]] (* 9699690 *) You can list those primes: Prime[Range[8]] You can answer the generalized problem from the below figure, e.g., How many distinct, sequential, smallest prime factors are needed to get a number ...

1

As @Mr.Wizard showed, IntegerPartitions answers both your questions directly, and he warned that it will be slow for large $n$ because it calculates all possible partitions. There is a faster answer to your first question of finding just one partition of even $n=p+q$. Set $p\le q$, and note that usually $p$ is a small prime. The function GoldbachTest uses a ...

Only top voted, non community-wiki answers of a minimum length are eligible