How to compute $5^{64} \pmod{193}$?  My idea was:  $5^{64} = (5^4)^{16} \equiv 625^{16} \equiv 46^{16}\pmod{193}$.  Now I don't understand why it's $46^{16} \equiv (-7)^8 \equiv 49^4 \equiv 85^2 \equiv 84 \pmod{193}$.  How to get it here and how can the power be reduced?
How do I efficiently compute $a^b\bmod c$:  When $b$ is huge, for instance $5^{844325}\bmod 21$? When $b$ is less than $c$ but it would still be a lot of work to multiply $a$ by itself $b$ times, for instance $5^{69}\bmod 101$? When $(a,c)\ne1$, for instance $6^{103}\bmod 14$?  Are there any other tricks for evaluating exponents in modular arithmetic?  This is being asked in an effort to cut down on duplicates, see  and .
The product of $n$ consecutive integers is divisible by $n$ factorial Expected value of subset of variables in Bayesian setting Assume we have $N$ random variables $X_1, \ldots, X_N$ with known (posterior) distributions that are easy to sample from. For simplicity, assume that I am interested in the expected value of the ten largest of these random variables. There will be some uncertainty surrounding this expected value as there is uncertainty with respect to the rank of a given $X_i$ in case the distributions of $X_1, \ldots, X_N$ overlap. I want to use simulation based methods. My approach is to simulate $M$ samples from the distributions of $X_1, \ldots, X_N$, where in each iteration, I construct a binary indicator of length $N$ indicating whether random variable $i$ is within the set of the ten largest samples or not. Averaging over these $M$ draws gives me the probability that random variable $i$ is member of the top ten group. Denote this probability as $\pi_i$. Define a binary random variable that indicates membership in the top ten group as $S_i$. $S_i$ follows a Bernoulli distribution s.t. $S_i \sim Ber(\pi_i)$. In a second step, I draw $L$ samples from the distribution of $S_i$ and from the distributions of $X_1, \ldots, X_N$. Given a draw of $S_i$, I can select the top ten out of the samples of $X_1, \ldots, X_N$ in each iteration and average the respective samples within the top ten group. I save this average, so the result after $L$ iterations will be the distribution of the average outcome within the top ten group, taking into account all relevant sources of uncertainty. My questions are: Is this simulation approach valid in general? From a Bayesian perspective, is this simulation valid or do I need to treat additional quantities (e.g. $S_i$ or $\pi_i$) as random variables that need a prior? Use of var keyword in C# After discussion with colleagues regarding the use of the 'var' keyword in C# 3 I wondered what people's opinions were on the appropriate uses of type inference via var?  For example I rather lazily used var in questionable circumstances, e.g.:-  foreach(var item in someList) { // ... } // Type of 'item' not clear. var something = someObject.SomeProperty; // Type of 'something' not clear. var something = someMethod(); // Type of 'something' not clear.   More legitimate uses of var are as follows:-  var l = new List&lt;string&gt;(); // Obvious what l will be. var s = new SomeClass(); // Obvious what s will be.   Interestingly LINQ seems to be a bit of a grey area, e.g.:-  var results = from r in dataContext.SomeTable               select r; // Not *entirely clear* what results will be here.   It's clear what results will be in that it will be a type which implements IEnumerable, however it isn't entirely obvious in the same way a var declaring a new object is.  It's even worse when it comes to LINQ to objects, e.g.:-  var results = from item in someList               where item != 3               select item;   This is no better than the equivilent foreach(var item in someList) { // ... } equivilent.  There is a real concern about type safety here - for example if we were to place the results of that query into an overloaded method that accepted IEnumerable&lt;int&gt; and IEnumerable&lt;double&gt; the caller might inadvertently pass in the wrong type.  var does maintain strong typing but the question is really whether it's dangerous for the type to not be immediately apparent on definition, something which is magnified when overloads mean compiler errors might not be issued when you unintentionally pass the wrong type to a method. QT MySql connectivity using Windows XP, Qt Creator 4.5.2(windows 32 bit) How can I use adb to send a longpress key event? Does "It snowed hard Monday" require an "on"? I came across an English learner writing     It snowed hard Monday.   After saying that it didn't snow on Friday and Saturday.  It didn't quite feel right to me.  I'd be okay with     It snowed hard.   or     It snowed Monday.   Is it okay for there to be two things ("hard" and "Monday") modifying the snowing without an "on" breaking things up a bit? If $Ax = Bx$ for all $x \in C^{n}$, then $A = B$. Let $A$ and $B$ are $n\times n$ matrices and $x \in C^{n}$.  If $Ax = Bx$ for all $x$ then $A = B$. To prove this I have selected  $x$ from Euclidean basis B = {$e_{1},e_{2},...,e_{n}$}. Then $Ae_{i} = Be_{i}$ implies $i^{th}$ column of A = $i^{th}$ column of B for all $1 \leq i \leq n$. Hence $A = B.$    Is this proof complete? setuid root does not work Objective : Run a program as root (C++ binary). The same as :   And :   ./a.out output:  E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? psurana  //output for "whoami" Look below for the code.   ls -l output:  -rwsrwxr-x 1 root    root    46136 Jun  7 20:13 a.out  The Code :   #include &lt;string&gt; #include &lt;stdlib.h&gt; int main(int argc, char *argv[]){         std::string input = "apt-get install " + std::string(argv[1]);         system(input.c_str());         system("whoami");         return 0; }   Details: : compiled the program and then did chown root:root a.out &amp;&amp; chmod u+s a.out. Please look above for ls -l output.  I still do not get the root privileges and the output for system("whoami") in the code is my own username on the machine.  Reading the two linked questions did not yield me anywhere. :(. both the creator and the owner of the file are root. The setuid bit is set, so it should work. The filesystem is not external either, it is my own machine. How can I make this work? Finish an activity after a time period Can the JVM recover from an OutOfMemoryError without a restart Do airlines have to check the visa status before selling a ticket? Prove that:  $$\displaystyle \sum_{n=m+1}^\infty \dfrac{1}{n!} \le \dfrac{1}{m\cdot m!}$$  I have tried induction on $m$ but it does not work very well. Any suggestion? Whenever I try to install anything with the Ubuntu Software Center, the following error appears.     Failed to download repository information      Check your Internet connection.      E:Unable to parse package file /var/lib/apt/lists/partial/archive.ubuntu.com_ubuntu_dists_precise_multiverse_i18n_Index (1) How to list all files ordered by size I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder. What is the time complexity of conjugate gradient method? I have been trying to figure out the time complexity of the conjugate gradient method.  I have to solve a system of linear equations given by  $$Ax=b$$  where $A$ is a sparse, symmetric, positive definite matrix.  What would be the time complexity of the conjugate gradient method? How to influence the position of float environments like figure and table in LaTeX? Here's the context       "Her heart leaping into her throat, she tiptoed into the salon. Such was her astonishment at seeing Mike chatting with her boss that she leaned against the wall, incapable of making another move."   Is this a phrase or what? Could it be used in other forms as well? Equal simple field extensions? I have a question about simple field extensions.  For a field $F$, if $[F(a):F]$ is odd, then why is $F(a)=F(a^2)$? Is it okay to say "Yes you're." instead of "Yes you are."? Possible Duplicate:    I was having an SMS conversation with a friend and somehow &quot;Yes you're&quot; came into play in retaliation to a comment. Example:  Person 1: &quot;You are bad at English&quot;. Person 2: &quot;No I are not.&quot;. Person 1: &quot;Yes you're&quot;.  Is that acceptable? I would assume that it is. Think of &quot;don't&quot;. You can say:  &quot;No, don't.&quot;  or  &quot;I don't.&quot;  and it is a contraction like &quot;you're&quot;. So, is it okay? I need to match a space character in a PHP regular expression. Anyone got any ideas?  I mean like "gavin schulz", the space in between the two words. I am using a regular expression to make sure that I only allow letters, number and a space. But I'm not sure how to find the space. This is what I have right now:  $newtag = preg_replace("/[^a-zA-Z0-9s|]/", "", $tag);