List of invertible congruence classesMathematica Semilog (LogLinearPlot) using x,y points from tableDefine a...

"Starve to death" Vs. "Starve to the point of death"

What is the difference between "...", '...', $'...', and $"..." quotes?

Potential client has a problematic employee I can't work with

Why did Luke use his left hand to shoot?

Why avoid shared user accounts?

Possible issue with my W4 and tax return

Which RAF squadrons and aircraft types took part in the bombing of Berlin on the 25th of August 1940?

How can I play a serial killer in a party of good PCs?

Why maximum length of IP, TCP, UDP packet is not suit?

Does the ditching switch allow an A320 to float indefinitely?

Why is it that Bernie Sanders is always called a "socialist"?

What makes papers publishable in top-tier journals?

Is there a file that always exists and a 'normal' user can't lstat it?

Custom shape shows unwanted extra line

What species should be used for storage of human minds?

Boss asked me to sign a resignation paper without a date on it along with my new contract

How much mayhem could I cause as a fish?

Is `Object` a function in JavaScript?

What is a good reason for every spaceship to carry a weapon on board?

Does it take energy to move something in a circle?

Why is the "Domain users" group missing from this PowerShell AD query?

Why do we have to make "peinlich" start with a capital letter and also end with -s in this sentence?

Where do we learn that students are like offspring?

Count repetitions of an array



List of invertible congruence classes


Mathematica Semilog (LogLinearPlot) using x,y points from tableDefine a function on a parameter argument set to zeroPolynomial GCD over a ring (with composite characteristic)How to properly inject iterators into table?Error Resulting from Placing a Dynamic Variable inside of TableFast calculation of discrete logarithmsWhat is the most straightforward solution to save integers right aligned into a text file?How to remove symmetries from this list?Creating iterations on a circle using the Table functionTable and evaluation order













2












$begingroup$


I am attempting to create a list of the invertible congruence classes $bmod 120$.



The code I have is Table[If[{ModularInverse[i, 120]} = {}, 120, ModularInverse[i, 120]], {i,
0, 119}]



If the modular inverse does not exist, it should return $120$. If it does exist, it should return the integer that corresponds to the inverse congruence class.



The code is not working how I expected it to. If the modular inverse does not exists, it gives me a list with the unevaluated code, for example, ModularInverse[0, 120].










share|improve this question











$endgroup$












  • $begingroup$
    Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
    $endgroup$
    – Michael E2
    5 hours ago
















2












$begingroup$


I am attempting to create a list of the invertible congruence classes $bmod 120$.



The code I have is Table[If[{ModularInverse[i, 120]} = {}, 120, ModularInverse[i, 120]], {i,
0, 119}]



If the modular inverse does not exist, it should return $120$. If it does exist, it should return the integer that corresponds to the inverse congruence class.



The code is not working how I expected it to. If the modular inverse does not exists, it gives me a list with the unevaluated code, for example, ModularInverse[0, 120].










share|improve this question











$endgroup$












  • $begingroup$
    Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
    $endgroup$
    – Michael E2
    5 hours ago














2












2








2





$begingroup$


I am attempting to create a list of the invertible congruence classes $bmod 120$.



The code I have is Table[If[{ModularInverse[i, 120]} = {}, 120, ModularInverse[i, 120]], {i,
0, 119}]



If the modular inverse does not exist, it should return $120$. If it does exist, it should return the integer that corresponds to the inverse congruence class.



The code is not working how I expected it to. If the modular inverse does not exists, it gives me a list with the unevaluated code, for example, ModularInverse[0, 120].










share|improve this question











$endgroup$




I am attempting to create a list of the invertible congruence classes $bmod 120$.



The code I have is Table[If[{ModularInverse[i, 120]} = {}, 120, ModularInverse[i, 120]], {i,
0, 119}]



If the modular inverse does not exist, it should return $120$. If it does exist, it should return the integer that corresponds to the inverse congruence class.



The code is not working how I expected it to. If the modular inverse does not exists, it gives me a list with the unevaluated code, for example, ModularInverse[0, 120].







number-theory modular-arithmetic






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 40 mins ago









J. M. is computer-less

96.9k10303463




96.9k10303463










asked 6 hours ago









pmacpmac

182




182












  • $begingroup$
    Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
    $endgroup$
    – Michael E2
    5 hours ago


















  • $begingroup$
    Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
    $endgroup$
    – Michael E2
    5 hours ago
















$begingroup$
Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
$endgroup$
– Michael E2
5 hours ago




$begingroup$
Not the only problem, but one thing to note: Equality is tested with a double-equals ==.
$endgroup$
– Michael E2
5 hours ago










1 Answer
1






active

oldest

votes


















4












$begingroup$

Note what happens when i does not have an inverse:



ModularInverse[2, 120]



ModularInverse::ninv: 2 is not invertible modulo 120.




(*  Out[]=  ModularInverse[2, 120]  *)


The output is the same as the input (it returns "unevaluated" in Mma jargon).
You can use FreeQ to see if the inverse returned unevaluated:



Table[With[{inv = Quiet@ModularInverse[i, 120]}, 
If[FreeQ[inv, ModularInverse], inv, 120]], {i, 0, 119}]





share|improve this answer









$endgroup$













  • $begingroup$
    You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
    $endgroup$
    – J. M. is computer-less
    37 mins ago











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192224%2flist-of-invertible-congruence-classes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4












$begingroup$

Note what happens when i does not have an inverse:



ModularInverse[2, 120]



ModularInverse::ninv: 2 is not invertible modulo 120.




(*  Out[]=  ModularInverse[2, 120]  *)


The output is the same as the input (it returns "unevaluated" in Mma jargon).
You can use FreeQ to see if the inverse returned unevaluated:



Table[With[{inv = Quiet@ModularInverse[i, 120]}, 
If[FreeQ[inv, ModularInverse], inv, 120]], {i, 0, 119}]





share|improve this answer









$endgroup$













  • $begingroup$
    You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
    $endgroup$
    – J. M. is computer-less
    37 mins ago
















4












$begingroup$

Note what happens when i does not have an inverse:



ModularInverse[2, 120]



ModularInverse::ninv: 2 is not invertible modulo 120.




(*  Out[]=  ModularInverse[2, 120]  *)


The output is the same as the input (it returns "unevaluated" in Mma jargon).
You can use FreeQ to see if the inverse returned unevaluated:



Table[With[{inv = Quiet@ModularInverse[i, 120]}, 
If[FreeQ[inv, ModularInverse], inv, 120]], {i, 0, 119}]





share|improve this answer









$endgroup$













  • $begingroup$
    You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
    $endgroup$
    – J. M. is computer-less
    37 mins ago














4












4








4





$begingroup$

Note what happens when i does not have an inverse:



ModularInverse[2, 120]



ModularInverse::ninv: 2 is not invertible modulo 120.




(*  Out[]=  ModularInverse[2, 120]  *)


The output is the same as the input (it returns "unevaluated" in Mma jargon).
You can use FreeQ to see if the inverse returned unevaluated:



Table[With[{inv = Quiet@ModularInverse[i, 120]}, 
If[FreeQ[inv, ModularInverse], inv, 120]], {i, 0, 119}]





share|improve this answer









$endgroup$



Note what happens when i does not have an inverse:



ModularInverse[2, 120]



ModularInverse::ninv: 2 is not invertible modulo 120.




(*  Out[]=  ModularInverse[2, 120]  *)


The output is the same as the input (it returns "unevaluated" in Mma jargon).
You can use FreeQ to see if the inverse returned unevaluated:



Table[With[{inv = Quiet@ModularInverse[i, 120]}, 
If[FreeQ[inv, ModularInverse], inv, 120]], {i, 0, 119}]






share|improve this answer












share|improve this answer



share|improve this answer










answered 6 hours ago









Michael E2Michael E2

148k12198476




148k12198476












  • $begingroup$
    You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
    $endgroup$
    – J. M. is computer-less
    37 mins ago


















  • $begingroup$
    You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
    $endgroup$
    – J. M. is computer-less
    37 mins ago
















$begingroup$
You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
$endgroup$
– J. M. is computer-less
37 mins ago




$begingroup$
You can also use Check[]: Table[Quiet[Check[ModularInverse[i, 120], 120, ModularInverse::ninv]], {i, 0, 119}].
$endgroup$
– J. M. is computer-less
37 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192224%2flist-of-invertible-congruence-classes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...