2
$\begingroup$

Considier the remainder of the first $2500$ prime numbers by the numbers from $3$ to $30$, included.

  1. Calculate how many primes are in each remainder class. That is, create a list that for each number between $3$ and $30$, gives for each remainder class the number of primes in it. Example. the first $5$ primes are: $2,3,5,7,11$. If we consider the remainders by $3$, we have: $2,0,2,1,2$. That is: $1$ with remainder $0$; $1$ with remainder $1$ and $3$ with remainder $2$.

I am having trouble condensing my program because I need to create a list for each number between 3 to 30. How could I add the remainders $3$ to $30$ to my program before it counts how many primes are in each remainder class.

I shortened just to see what is happening (ie. I shortened $2500$ to $5$)

list = Sort[Flatten[Table[n, {n, 1, 5}]]];
PrimeQ[list];
primelist = 
Length[Select[list, PrimeQ]] ;
divide = Mod[Total /@ list, 3]; 
remainder2 = Count[divide, 2]
remainder1 = Count[divide, 1]
remainder0 = Count[divide, 0]

results were:

    {2, 3, 5, 7, 11}
    {True, True, True, True, True}
    3
    1
    1
$\endgroup$
0
4
$\begingroup$
n = 2500;
m = 21;
primes = Prime[Range @ 2500];

Counts[Mod[primes, #]] & /@ Range[3, m] // Column

enter image description here

If you wish you can reorganize the information above into a Dataset:

KeyMap[ToString] /@ KeySort /@ KeyUnion[Counts[Mod[primes, #]] & /@ Range[3, m]] // 
  MapIndexed[Join[Association["m" -> ToString[#2[[1]] + 2]], 
     Association["remainderClass" -> #]] &] // Dataset

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.