# Tag Info

10

You are right!! Reverse /@ Table[IntegerDigits[Prime[i]], {i, 549, 2, -1}] // Flatten // FromDigits // PrimeQ True 7693749334931393929332939193719311937093988318837783368335831583748333\ 8332831283308379733973977396737673167393733373727391739073107379631963\ 7763376317639563346373631363326371633163706339533853185317539553755374\ ...

7

Your G is called IntegerExponent[] in Mathematica: Table[IntegerExponent[5^2 7^3 11^4, k], {k, {5, 7, 11}}] {2, 3, 4} You should now be able to use that function to write your function F.

6

Use the option DataReversed: ArrayPlot[table, Frame -> True, FrameTicks -> {Range, Range}, DataReversed -> True, Mesh -> All] table2 = Table[Boole[And @@ PrimeQ[{m, n}]], {m, 13}, {n, 13}]; ArrayPlot[table2, Frame -> True, FrameTicks -> {Range, Range}, DataReversed -> True, Mesh -> All]

6

Clear["Global*"] f[s_] = 1 - Sin[Pi Gamma[s]/s]/Sin[Pi/s]; Since you are interested in integral roots sol = s /. Solve[{f[s] == 0, 2 <= s < 100}, s, Integers] {* {2, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97} *) The integral roots are prime And @@ PrimeQ[sol] (* True *) These are all of ...

6

You can add a constraint to your Solve: Solve[Prime[n] - Prime[m] == 8 && 0 < m < n < 100, {n, m}, Integers] {{n -> 5, m -> 2}, {n -> 6, m -> 3}, {n -> 8, m -> 5}, {n -> 11, m -> 9}, {n -> 12, m -> 10}, {n -> 18, m -> 16}, {n -> 19, m -> 17}, {n -> 22, m -> 20}, {n -> 25, m -> 24}, {n -> 29, m -> 26}, {n -> 34, m -> 32}, {...

5

Mathematica has a lot of prime functionality built in. In particular PrimeQ[x] gives True if x is prime and false otherwise, and PrimePi[x] counts the number of primes less than or equal to x. So, it seems like you want something like numPrime[n_] := If[PrimeQ[n], PrimePi[n], Null] so that numPrime=7 and numPrime is Null (or you could print ...

5

try this Total@IntegerDigits[2^57885161 - 1] 78434761 Total@IntegerDigits[2^74207281 - 1] 100537543 Total@IntegerDigits[2^77232917 - 1] 104621260 or use this function M[x_]:=Total@IntegerDigits[2^x-1] M 111879913

5

The period of the decimal expansion of a fraction $p/q$ is equal to the multiplicative order of $10 \mkern-10mu \mod q^*$, where $q = 2^a5^bq^*$ and neither $2$ nor $5$ divides $q^*$. ClearAll[fracPer, vp]; (* p-adic order *) vp[p_?PrimeQ, n_Integer] := Length@NestWhileList[#/p &, n/p, IntegerQ] - 1; (* fraction decimal expansion period *) fracPer[...

5

It is not clear how you want these Ramanujan primes displayed. The following uses NumberLinePlot (introduced in v10.0) l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}]; rp = 1 + Last[Position[l, #]][] & /@ Range[0, 50]; NumberLinePlot[Tooltip /@ rp, ImageSize -> Large] EDIT: Using ArrayPlot with Manipulate Manipulate[ ArrayPlot[ Array[Boole[...

4

The code for DotPlot is a starting point that needs to be tailored (e.g., add or modify ListPlot options) for specific applications. It is not clear to me what you are asking for, so I have tailored DotPlot for displaying the prime factors of 50! DotPlot[data_] := Module[{m = Tally[Sort[data]]}, ListPlot[Flatten[Table[{#1, n}, {n, #2}] & @@@ m, 1], ...

3

Clear["Global*"] Sequence A000040 can be easily found using FindSequenceFunction A000040 = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41}; fA000040 = FindSequenceFunction[A000040] (* Prime *) Verifying, A000040 == fA000040 /@ Range[Length@A000040] (* True *) Or, since Prime is Listable A000040 == fA000040@Range[Length@A000040] (* True *)

3

Clear[allprimes] allprimes[x_] = For[i = 0, i <= x, i++, If[PrimeQ[i], Print[i]]] Look at the stored definition of allprimes ?allprimes Since you use Set the RHS evaluated immediately and was equal to Null. Use SetDelayed Clear[allprimes] allprimes[x_] := For[i = 0, i <= x, i++, If[PrimeQ[i], Print[i]]] The stored definition is then ?allprimes ...

3

You can use the functions Prime, PrimePi and Range: ClearAll[primesLessThanOrEqualTo] primesLessThanOrEqualTo[x_] := Prime[Range[PrimePi[x]]] primesLessThanOrEqualTo {2, 3, 5, 7, 11, 13, 17, 19} A fancier way to define the same function as a pure function (composition of the three functions): ClearAll[primesLessThanOrEqualTo2] ...

2

Is this what you mean? The decimal representation of a*b*c*d*e*f*g*h*i*j*k has the repeating digits {4, 6, 5, 0, 2, 0, 5, 7, 6, 1, 3, 1, 6, 8, 7, 2, 4, 2, 7, 9, 8, 3, 5, 3, 9, 0, 9}, which is a sequence of length 27: RealDigits[a*b*c*d*e*f*g*h*i*j*k] {{3, 1, 6, 3, 7, 3, 8, 3, 9, 1, 1, 8, 5, 0, 7, 5, 7, 6, 7, 1, 3, 1, 5, 7, 6, 4, 8, 4, 7, 7, 6, 6, 0, ...

2

junk = Table[ FromDigits@Reverse@IntegerDigits[Prime[i]], {i, 2, 549}]; final = FromDigits[Flatten[IntegerDigits /@ junk]]; PrimeQ[final] (* False *) This takes $0.002238$ seconds on a Mac laptop.

2

Here is a slightly variant variant version of @AccidentalFourierTransform and @Nasser answer. z = Prime[Range]; Table[If[PrimeQ[z[[i]] + 8] == True, {z[[i]], z[[i]] + 8},Nothing], {i, Length@z}] {{3, 11}, {5, 13}, {11, 19}, {23, 31}, {29, 37}, {53, 61}, {59, 67}, {71, 79}, {89, 97}, {101, 109}, {131, 139}, {149, 157}, {173, 181}, {191, 199}...

2

another possible way to generate them is (for first 100 primes) ClearAll[n, m, i, j, z]; z = Prime[Range]; (Last@Reap@Do[ Do[If[z[[i]] - z[[j]] == 8, Sow[{n -> z[[i]], m -> z[[j]]}]], {i, 1, Length@z}], {j, 1,Length@z}])[]

2

It doesn't work because there is (conjecturally) an infinite number of solutions. You can use e.g. Flatten[Table[If[Prime[n] - Prime[m] == 8, {n, m}, Nothing], {n, 1, 100}, {m, 1, 100}], 1] to generate the first few pairs: {{5, 2}, {6, 3}, {8, 5}, {11, 9}, {12, 10}, {18, 16}, {19, 17}, {22, 20}, {25, 24}, {29, 26}, {34, 32}, {37, 35}, {42, 40}, {46, 43}, {...

2

Use FindGeneratingFunction to derive the generating function for a sequence. Recall that the power series of a generating function encodes the sequence in its coefficients. Also FindGeneratingFunction, FindSequenceFunction, InterpolatingPolynomial can be used with Series but this would be wasteful if these series are well-kown. Also instead of using a For ...

2

I think the simplest working variation of your code is enter[n_] := Count[Range[2, n], _?PrimeQ] The function Count takes a pattern (look it up in the help). In this case, I'm matching anything that PrimeQ recognises as a prime.

1

Because of the highly oscillatory nature of the function under consideration, an NDSolve[]-based method with event location (discussed by Daniel in this answer) seems appropriate, as it is more likely to be careful about traversing the function under consideration. Of course, the price to pay for this carefulness is that the evaluations take quite a while. ...

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