3
$\begingroup$

So I know how to get half of this problem. I am trying to run a loop that combines the following two function at once so I can see from my index i if any number satisfies both conditions.

TO get the Sum of divisors mod a prime I write:

Table[{i,DivisorSigma[1,i]},{i,20}] // Mod[#,13] & 

That code works great , I also want to know if the number is a perfect square. I use a similar code for that using Table[Sqrt[i],{i,20}] . What I want to know now is if I can compare both things side by side in my table or a column so something like:

Table[{i,Sqrt[i],DivisorSigma[1,i]},{i,20}] // Mod[#,13]&

Side note: The only down side to that type of code would be that it would mod the square root mod 13 and I just want to see if the number is a perfect square.

$\endgroup$
  • 2
    $\begingroup$ {Mod[#, 13], Sqrt[#], Mod[DivisorSigma[1, #], 13]} & /@ Range@20 $\endgroup$ – OkkesDulgerci Mar 7 at 23:17
4
$\begingroup$
Table[Riffle[Mod[{i, DivisorSigma[1, i]}, 13], Sqrt[i]], {i, 20}]

{{1, 1, 1}, {2, Sqrt[2], 3}, {3, Sqrt[3], 4}, {4, 2, 7}, {5, Sqrt[5], 6}, {6, Sqrt[6], 12}, {7, Sqrt[7], 8}, {8, 2 Sqrt[2], 2}, {9, 3, 0}, {10, Sqrt[10], 5}, {11, Sqrt[11], 12}, {12, 2 Sqrt[3], 2}, {0, Sqrt[13], 1}, {1, Sqrt[14], 11}, {2, Sqrt[15], 11}, {3, 4, 5}, {4, Sqrt[17], 5}, {5, 3 Sqrt[2], 0}, {6, Sqrt[19], 7}, {7, 2 Sqrt[5], 3}}

Also

MapAt[Mod[#, 13] &, Table[{i, Sqrt[i], DivisorSigma[1, i]}, {i, 20}], {All, {1, 3}}]

same result

$\endgroup$
  • $\begingroup$ Spectacular thank you $\endgroup$ – argamon Mar 7 at 23:09
  • $\begingroup$ @argamon, you are welcome. $\endgroup$ – kglr Mar 7 at 23:09

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.