I am not sure of the correct mathematical name of the feature I am looking at. Its been a long time since I did math at school.   seems to concerned with this sort of thing, but leaves me unsure that I have understood what is written. Below I use '%' as MOD and '^' as 'raised to the power of'.  And am quite wordy. For all primes &gt; 2, there is a sequence {2^n%prime, for all integer n, 0 to infinity}. That is { 2^0 % prime = 1, 2^1 % prime = 2, .. 2^(prime-1) % prime = 1, 2^prime % prime = 2, ..} 2^((prime-1) * m)%prime = 1 and 2^(prime * m)%prime = 2 for all integer m. if the prime is 7 however, the sequence is made up of two instance of a shorter sequence thus: 2^0%7 = 1, 2^1%7 = 2, 2^2%7 = 4, 2^3%7 = 1, 2^4%7 = 2, 2^5%7 = 4, 2^6%7 = 1 and then 2^(6 * n)%7 is still 1; but the are extra values that are also another set of at (2^(3+6*n)%7) So the cycle-length(prime) is what I have been calling the first n &gt; 0 where 2^n mod prime is 1. I have inserted some code that calculates this by trial until repetition.. with some trivial uses of it. long cycleLength(long prime) {     long remainder = 1 ;     long length = 0 ;      do {         length++ ; //#define FAST_MODULO #ifdef FAST_MODULO         remainder = (remainder+remainder)%prime ; #else         remainder += remainder ;         if (remainder &gt; prime) remainder -= prime ; #endif         if (remainder == 1)             return length ;     } while (length &lt; prime/2) ;      return prime-1 ;}  size_t pow_of_2(unsigned n) {     size_t result = 1 ;     size_t pow = 2 ;      while(n)     {         if (n &amp; 1) result *= pow ;         pow *= pow ;         n /= 2;     }     return result ; }  #include &lt;iostream&gt; using std::cout ;  int main(int ac, char **av) {     long prime = 17 ;      cout &lt;&lt; &quot;cycleLength(17) = &quot; &lt;&lt; cycleLength(17) &lt;&lt; '\n';      cout &lt;&lt; &quot;2^16 = &quot; &lt;&lt; pow_of_2(16) &lt;&lt; '\n' ;     cout &lt;&lt; &quot;2^33 = &quot; &lt;&lt; pow_of_2(33) &lt;&lt; '\n' ;      cout &lt;&lt; &quot;33 % CL(17) = &quot; &lt;&lt; 33 % cycleLength(17)           &lt;&lt; &quot;, 2^(33 % CL(17)) % 17 = &quot; &lt;&lt; pow_of_2(33%cycleLength(17)) % 17 &lt;&lt; '\n' ;     cout &lt;&lt; &quot;2^33 % 17 = &quot; &lt;&lt; pow_of_2(33)%17 &lt;&lt; '\n' ;     cout &lt;&lt; std::endl ; }  I have observed that cycles are either length (prime-1) or divisor of (prime-1). So the run-time is reduced by stopping at (n == prime/2) and returning (prime-1) as that is the only case remaining; and the code is about 25% quicker as a result. The algorithm is currently O(N) time complexity. I am hoping for clues or insight that might reduce this. Thanks for reading this.
If I take the $k \in \mathbb{N}$ power of 10 and mod it by a large prime, I notice that the remainders repeat at some point.  For instance $10^k mod~7$ seems to repeat every $8$th value of $k$.  Given $k$ (the power of ten), and a large prime number $p$, how can I compute the size of the cycle?  I tried writing a python script that computes the first instance of a repeat. However, I don't know if this works since a single instance of a repeat may not necessarily mean a full cycle.
Find the infinite sum of the series $\sum_{n=1}^\infty \frac{1}{n^2 +1}$ This is a homework question whereby I am supposed to evaluate:  $$\sum_{n=1}^\infty \frac{1}{n^2 +1}$$  Wolfram Alpha outputs the answer as   $$\frac{1}{2}(\pi \coth(\pi) - 1)$$  But I have no idea how to get there. Tried partial fractions (by splitting into imaginary components), tried comparing with the Basel problem (turns out there's little similarities), nothing worked. I want a translucent PNG overlayed on top of my screen (above all windows). I'm using this to mark a visible region while streaming.   So far I've figured out that qiv -transparent filename.png will add a mask to the window, but it's a boolean mask. I don't get translucent fading with the alpha channel.  I know several effects have opacity, and I can sent window opacity, so I'm hoping there's some way to display an image that way.  What program, tool, or widget can I use to blend an image onto the top of the desktop? How to migrate MongoDB 2.4.14 file to MongoDB 3.6? I have a database file from MongoDB 2.4 and we want use this on mongodb 3.6.  note: the file is original from the db path. Not from mongodump. This process is messy as it requires doing so on many of our clients.  Any advice will be welcomed as I'm a bit lost in this process.  Thanks If I'm floating in space and I turn on a flashlight, will I accelerate? Photons have no mass but they can push things, as evidenced by .   Can photons push the source which is emitting them? If yes, will a more intense flashlight accelerate me more? Does the wavelength of the light matter? Is this practical for space propulsion? Doesn't it defy the law of momentum conservation?  Note: As John Rennie mentioned, all in all the wavelength doesn't matter, but for a more accurate answer regarding that, see the comments in  .  Related Wikipedia articles: , Close and flag links do nothing on mobile site This morning (it's about six AM here) I find that I can no longer submit close votes; the link just jumps to the beginning of the page.  I'm on iOS, using a third-party browser called Grazing, but a brief check with Mobile Safari shows the same problem there.   Here on Meta, where my score is much lower, I only get a "delete" link on my own question, and that works fine. (Oops :-))   Update: As per comments, this affects the "flag" link, too, which doesn't even scroll to the top of the page. Update 2: Latest comment suggests this affects Android, too. Update 3: This also affects desktop computers when viewing mobile (when you click "mobile" in the footer) Update 4:  mentions Windows 8, too; simply deleting platform-specific tags After upgrading to 15.04, I have one additional driver (it did not appear in 14.10). What is the purpose of this driver and should I enable it? What is time dilation really? Please will someone explain what time dilation really is and how it occurs? There are lots of questions and answers going into how to calculate time dilation, but none that give an intuitive feel for how it happens. error: Unable to find vcvarsall.bat (This is not homework; a friend shared with me this puzzler and neither of us can figure it out.) Suppose you are in a plane traveling at velocity $v_1$ relative to the ground. The flight attendent pushes a cart of mass, say, $m$, accelerating it from rest to $v_2$, relative to the plane (so relative to the ground, its velocity goes from $v_1$ to $v_1+v_2$). From your perspective, the work done is then $$W = \Delta E = \dfrac{1}{2}mv_2^2$$ but from the perspective of the ground, the work done is $$W = \Delta E = \dfrac{1}{2}m(v_1+v_2)^2 - \dfrac{1}{2}mv_1^2 = \dfrac{1}{2}mv_2^2 + mv_1v_2.$$ Why are these quantities unequal?  I've seen some similar problems, like a body colliding with a wall in different reference frames, but I don't have the physics experience to tell if that question is analogous to this one. So, my apologies if this is a duplicate. :) Self-promotion in chat We know from the  that it is accepted only in a limited way in answers and frowned upon if found to be spammy. We know from  that it can be deleted at any time from comments if the comment is not relevant or spammy.  But what about the chat? This leaves chat to be the only legitimate place to promote products or services that the user is affiliated to (albeit in an ad-like way).  What is your opinion? Compactness of a Sphere This fact is mentioned liberally in literature along with subsequent mention of Heine-Borel and I am trying to get my head around it. What would be a formal proof of this if we take for example, a unit sphere in $\mathbb R^3 $?  In addition, how could it be shown, non-trivially of course, that this sphere is not homeomorphic with $\mathbb R^2 $? As I understand this involves finding a bijective function with continuous inverse? With me going it alone in development I only have limited resources at my disposal i.e one pc with which I develop and test the game. so I only know for certain my game works with that setup.  What options have I got in testing the game on the many different hardware/operating system combinations? Its a windows desktop game. I'm getting a NoSuchMethodError error when running my Java program.  What's wrong and how do I fix it? Intraclass correlation coefficient vs. F-test (one-way ANOVA)? Are there any rules concerning what I can put in my profile? Does the full quarantine period have to be observed for short trips of less than 14 days to England? I am planning to go to England for 2 days in preparation of moving (I already have a place rented and would be staying there) a few weeks later. I am coming from a country where I would need to do a 14 day quarantine as soon as I enter England. Does this mean that I have to stay in England for 14 days or can I leave the country before the end of the 14 day quarantine without facing a penatly? I have found no information about what the rules are for planned stays of less than 14 days on the , while  seems to say that short trips are OK. Official sources would be appreciated. .bash_history does not update in Git for Windows (git bash) I have answered 'No' to Siri initial prompt, but I can still see it in my process list. I've tried to kill it, but it loads again immediately. How can I unload and remove Siri from my Mac? Please help me to find elements $a,b$ in a ring $R$ such that $a\mid b$ and $b\mid a$, but there does not exist any unit $u$ in $R$ such that $a=ub$. Why do I always hear remote train horn at night? This is definitely not an illusion, as many people have the same experience. I have usually lived in places miles away from train stations, which makes it unlikely to hear any train horns during the day. However at night, occasionally train horns can be heard. I hope if any one can explain the physics of this effect, like possibly sound travels faster at low temperature.