I know this is more of a 'aops' type of question but here we go, I went to this math competition last year and there was this one problem that clearly I didn't solve but it recently came back to my mind and I want to know how to go about such problem:  Find the last 4 digits of the number: $$2^{{10}^{2018}}$$  My intuition is that one should probably use modular arithmetic on this one, the first things that came to my mind when I saw this one where: Chinese remainder Theorem and Binomial sums, I wasn't able to do much unfortunately... I've read through the "How do I compute $a^b$ (mod c) by hand?" question but most of the answers rely on a and c being coprime which in my case $(2,10^4)=2$ is not true, the answers cover a few cases when a and c are not coprime but nothing very similar to my case...
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 .
How can I print the table of contents multiple times in my document? I am using also titletoc to improve how my table of contents. I would like to print the table of contents several times. How can I do it?  It does not work in the MWE:  \documentclass{article} \usepackage[utf8]{inputenc}  \begin{document}  \tableofcontents  \section{Hello} \section{Bye}  \tableofcontents  \end{document}     PS: I have this code in my document, in order to have no title for the table of contents.  \makeatletter \renewcommand\tableofcontents{%     \@starttoc{toc}% } \makeatother   PPS: \renewcommand{\contentsname}{}% Remove \tableofcontents' title/name will not work since I am using [french]{babel}. I am travelling form Delhi (DEL) to San Francisco (SFO), I have to make a connection flight in Vienna that would take me to Frankfurt (FRA). My flight to SFO is from FRA, I have one ticket for entire journey and the flights are operated by Lufthansa or its subsidiaries.  Do I need a transit visa? My flight arrives at Vienna international airport and leaves from the same, and for second leg it arrives at Frankfurt international airport.  I asked this question as an addendum to my  but was advised to make a new post.  I hold Indian passport and valid US visa. Why I think tension should be twice the force in a tug of war I'm going to provide my argument for why I think the tension in a rope should be twice the force exerted on either side of it.  First, let's consider a different example. Say, there is a person named A and a block in space. A pushes on the block with a force of 100 N. Then, the block will also push A with a force of 100 N by Newton's third law. Now, consider the case where instead of the block, there is a person B who is also pushing on A with a force of 100 N while A is pushing on him. A will experience a force of 100 N because he pushed on B, AND another 100 N because he is being pushed by B. Hence he will experience a force of 200 N. Similarly, B also experiences 200 N of force.  Now, back to the original problem. There are two people A and B in space with a taut rope (no tension currently) in between them. If only A is pulling and B is not, then I agree that the tension is equal to the force A exerts. This situation (in my opinion) becomes analogous to the above if B is also pulling. So, say both of them pull from either side with a force of 100 N. Then the rope at the end of B will pull B with a force of 100 N (this pull is caused by A). By Newton's third law, the rope will experience a pull of 100 N. But B is also pulling his end of the rope with 100 N. Therefore, the tension should be 200 N. Similarly, the end of the rope at A must pull A with 100 N of force (because B is pulling from the other side) and hence experience a force of 100 N itself by Newton's third law plus another 100 N because A is pulling on the rope.  Apparently, the answer is not this (according to my searching on the web). So, could anyone tell me why this reasoning is wrong? Thanks.  EDIT : So apparently people don't agree with my first example, leave alone the second. This is to the downvoters and the upvoters of the highest-rated answer: You all agree that if only A pushes B with a force of 100 N, then A and B both will get pushed by a force of 100 N in opposite directions, right? Then, in the case where B is also pushing with a force of 100 N, it doesn't make sense that the answer would be exactly the same. It doesn't seem right that no matter what B does, B and A will always experience the same force as they would have if B hadn't applied any force.  EDIT 2 : I'm going to provide here a link to a question that I posted:  According to the answer and the comments there, the reason as to why my first example is incorrect is different to the one provided here. So maybe you should all read the answer and the comments provided by the person and reconsider what you think. I installed vsFTPd for running an FTP server on  (Wheezy). I checked the vsFTPd version was 2.3.5, and I configured it like so:  listen=YES local_enable=YES write_enable=YES chroot_local_user=YES pasv_min_port=15000 pasv_max_port=15200 allow_writeable_chroot=YES   I followed these articles for solving this problem:       And many others on Google and forums, but my problem was not solved.  NOTE: I have solved this problem on  (Precise Pangolin), but that solution does not work on Debian 7.3.  I really mixed up on it?! Cutting features to do opposite of clipping in ArcGIS Desktop? What´s the easiest/smartest way of getting the opposite output of the clipping tool?   I just need the area of feature A1 which is not covered by feature A2 in a new Layer/File.  Now, I get the result by union´ing both features and deleting the "wrong" parts by hand.  I'm using ArcGIS Desktop 10. I am using an USB port as a power supply. Is there a way I can take the weak 5V of a regular laptop USB and transform if to 100V+ while begin in the smallest package possible. I've heard of boost converters but they are usualy too big. I want something that has the size of like a normal USB key.   What I want to do is to charge up around 5 capacitors at 100+V and then discharge them later. Power efficiency not a concern for me.  It would be helpful to include a schematic of the circuit. Suppress Fancy header and footer on first page only. evaluate the limit as $x$ approaches $0$ of $(\cos x-1)/x$ without l'Hopital's rule I know with l'Hopital's rule it becomes $-\sin(x)$ which has the limit $0$. However, I have been wondering how to evaluate this limit without l'Hopital's rule. "There are currently N bounties, worth X reputation" dynamic ad and the new sidebar width You've probably seen this sidebar ad on one or more -enabled Stack Exchange sites over the years:    The image is dynamically generated from a non-officially SE app that uses the Stack Exchange API to fetch the bounties from a given site.  As far as I understand, the rendered image automatically scales to the allotted ad space - when the sidebar ads were 220x250, it would render in the sidebar as a 220x250 image while still looking quite oversized in the  meta (as it does right here).  With the new 2016 campaign starting, can we test whether this awesome dynamic ad works with the new sidebar width? Have a look at the following code:  \documentclass[letterpaper]{article} \usepackage{amsmath,amssymb} \begin{document}  $2-\frac{2}{1-\left(\frac{2}{2-\frac{2}{x^2}}\right)}$\quad  $2-\dfrac{2}{1-\left(\dfrac{2}{2-\dfrac{2}{x^2}}\right)}$\quad  $2-\cfrac{2}{1-\left(\cfrac{2}{2-\cfrac{2}{x^2}}\right)}$\quad  $2-\dfrac{2}{1-\left(\cfrac{2}{2-\dfrac{2}{x^2}}\right)}$ \end{document}   This gives:    Evidently, the first display is not the proper way. The second and last are the same I guess. The third has a better display but there is too much space above the 2 in \left(\cfrac{2}{2-\cfrac{2}{x^2}}\right). Essentially, non of the above displays satisfies, for me, a good Mathematical typsetting. Although, it may be argued that it is the default in LaTeX. I just can't get it right? Any insights? In a book I got this example from it looks like this without the excessive bold (this is a scanned image): For example, this regex  (.*)&lt;FooBar&gt;   will match:  abcde&lt;FooBar&gt;   But how do I get it to match across multiple lines?  abcde fghij&lt;FooBar&gt; Variable-name \newcommand with parameters within another \newcommand Can you flash any android device with "fastbood flash" command (of the adb)? How can I create that glitter tears effect and the sparkles? I have a media server (Windows 8) located in a very inconvenient part of my house. Occasionally I will have to reset my router or it will reset itself. The issue is the PC loses connectivity for some reason, and I am forced to walk outside, around the house, into the basement, over a bunch of toys and weights and boxes, to push a button to reboot it.  I would love to have it check itself every 5-10 minutes and auto reboot if it is unable to ping a given address/IP.  Any ideas how to accomplish this? What is the minimum distribution for LaTeX Convert LaTeX to HTML Is there a converter that will convert LaTeX to HTML? I have tried several services but the LaTeX diagrams and some of the maths came out weird.  I actually converted the Latex to PDF without a problem. Then I used  to convert from PDF to HTML. The square root signs did not appear properly and some of the Cartesian coordinate plane diagrams had nothing on them except the grid.   \documentclass[12pt,a4paper]{report} \usepackage{amssymb} \usepackage{amsthm} \usepackage{amsmath} \usepackage{pstricks,pst-plot} \usepackage{pst-eucl} \addtolength{\hoffset}{0.2cm} \addtolength{\textwidth}{1.1cm} \addtolength{\textheight}{1.0cm} \addtolength{\voffset}{-0.7cm} \linespread{1.3} \begin{document}  If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$     $\hspace{30 mm} $     (6)\\  (4) and (6) tell us that\\  (4)  $-1 \leq x \leq 0$  \\  (6)  If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$\\  Therefore $-1 \leq x \leq -\sqrt{\frac{1}{2}}$\\  \vspace{50 mm}  \begin{align*} \psgrid[unit=2cm](0,0)(-2,-2)(2,2) \pnode(-1.8,.87){b}\uput[50](b){b} \pnode(-1.8,1.8){a}\uput[50](a){a} \psset{linecolor=green} \psline[linewidth=1pt](-1.8, 0)(-1.8,4) \psset{linecolor=green} \psline[linewidth=1pt](-1.8, 0)(-1.8,-4) \psset{linecolor=blue} \psellipticarc(0,0)(2,2){0}{180} \psset{linecolor=red} \psline[linewidth=1pt,linestyle=dashed,dash=2pt](-2,2)(-1.41,1.41) \psset{linecolor=red} \psline[linewidth=1pt](-1.41,1.41) \psset{linecolor=red} \psline[linewidth=1pt]{-&gt;}(4,-4) \psset{linecolor=red} \psline[linewidth=1pt]{-&gt;}(-2,2)(-4,4) \end{align*}  \end{document}   PDF output:    PDF->HTML output: Can I install pantheon terminal in Ubuntu 14.04 or newer? Is it possible to install Pantheon terminal from elementary OS on my Ubuntu 14.04 or newer LTS releases? If yes, how can I? How to prove $\det(I+uv^\intercal)=1+v^\intercal u$ Let be $u,v\in\mathbb{R}^n$, then $\det(I+uv^\intercal)=1+v^\intercal u $ where $I$ denotes the identity matrix of order $n$. How to prove this?   what I did:   let be $A=\{n\in\mathbb{N}: \forall u,v \in \mathbb{R^n}, \det(I+uv^\intercal)\neq1+v^\intercal u  \} $, and suppose $A\neq \varnothing $, then for the well-orderer-principle there exists $n_0\in A$ such $n_0\leq n,\;\forall n\in A$. since $1\notin A,\; n_0\neq 1 \rightarrow n_0-1\in\mathbb{N}\setminus A  $ so: $$\forall u,v\in\mathbb{R^{n_0-1}}: \det(I+uv^\intercal)=1+v^\intercal u $$ Then, let be $u,v\in\mathbb{R}^{n_0}$, so $$\det(I+uv^\intercal)= \displaystyle\sum_{j=1}^{n_0}(-)^{1+j}a_{1j}\det(A_{1j})$$ where $a_{ij}=\begin{cases} u_iv_j+1 &amp; i=j \\ u_iv_j &amp; i\neq j \end{cases}$, and $A_{1j}$ is the  submatrix of $I+uv^\intercal$ that results deleting the i-file and j-column. Then I try to open the term for $j=1$ and try to use the relation for the new matrix of $n_0-1$ order with the determinant because it holds the same form but I have other terms which difficult me the work. Do you know other method?.  Ps. , in page 2 I've found something similar but I don't understand what it means PS. I'm taking a course of numerical analisys Number of integer solutions of $x^2 + y^2 = k$ I'm looking for some help disproving an answer provided on a  I posted about computing the number of double square combinations for a given integer.    The original question is from the Facebook Hacker Cup       Source: Facebook Hacker Cup   Qualification Round 2011      A double-square number is an integer $X$   which can be expressed as the sum of   two perfect squares. For example, 10   is a double-square because $10 = 3^2 + 1^2$.   Given $X$, how can we determine the   number of ways in which it can be   written as the sum of two squares? For   example, $10$ can only be written as $3^2 + 1^2$   (we don't count $1^2 + 3^2$ as being different). On the other hand,   $25$ can be written as $5^2 + 0^2$ or as   $4^2 + 3^2$.      You need to solve this problem for $0 \leq X \leq 2,147,483,647$.      Examples:      $10 \Rightarrow 1$      $25 \Rightarrow 2$      $3 \Rightarrow 0$      $0 \Rightarrow 1$      $1 \Rightarrow 1$   In response to my original question about optimizing this for F#, I got the following response which I'm unable to confirm solves the given problem correctly.       Source:       Again, the number of integer solutions   of $x^2 + y^2 = k$ is four times the   number of prime divisors of $k$ which   are equal to $1 \bmod 4$.      Knowing this, writing a program which   gives the number of solutions is easy:   compute prime numbers up to $46341$ once   and for all.      Given $k$, compute the prime divisors of   $k$ by using the above list (test up to   $\sqrt{k}$). Count the ones which are   equal to $1 \bmod 4$, and sum. Multiply   answer by $4$.   When I go through this algorithm for $25$, I get $8$ which is not correct.          For each prime factor (pf) of $25$ ($5$, $5$ are prime factors of $25$)         if pf % $4$ = $1$ (true for both $5$'s), add $1$ to count      return $4$ * count (count would be $2$ here).          So for $25$, this would be $8$