What is the next number having the same number of bit 1s? You are given a number, $A$, and you have to determine a number, $B$, such that $B&gt;A$ and the number of $1's$ in the binary representation of $A =$ number of $1's$ in the binary representation of $B$.  What is the smallest $B$?
Computing the $n^{\textrm{th}}$ permutation of bits. I've seen  post about the $n^{\textrm{th}}$ permutation of a set but that is not what I need. If you have a bit string (ones and zeros only) there are  to quickly permute the NEXT lexicographically ordered bit permutation. For example take $$000111 \rightarrow 001011 \rightarrow 001101\rightarrow\cdots$$ etc. If the string is long then there are going to be approximately one Bajillion of these things. And I want to know how to compute the $n^{\textrm{th}}$ guy without doing the exhaust.  Backgound: This is for a parallel computing job where I need to farm out the search space of elements of a set.  Foreground: I own a copy of Knuth's 4th volume of "The Art of Computer Programming" and I think the answer is in there but I can't seem to find it. (It's like 900 pages).  I'm posting here in the hopes that someone has knowledge of this (obviously). Even if you can point me to a source, say the part in Knuth's book where he describes this problem I would be most grateful.
Find all solutions of the equation $n^m=x^2+py^2$ which satisfy the following properties Prove or disprove that,     There always exists a solution of the equation, $$n^m=x^2+py^2$$ with odd $x$ and $y$ and for all $m\geq k$ for some positive integral $k$. Here $p$ is an odd prime and $n\in 2\mathbb{N}$. Is $k$ dependent on $n$? If so then find a way to calculate the value of $k$.   This is basically one of my conjecture which I am trying to prove for quite sometime. Unfortunately, I have progressed very little in this problem. So far I have been only able to prove that for all $m\geq3$ , $n=2$ and $p=7$ there is always a solution of the equation meeting the constraints.   Any idea how to tackle the problem?    Update  After D. Burde's answer of the original problem (see below) I am now interested in finding all $(n,m,p)$ triplets such that the equation holds. Any ideas regarding this problem? Remove empty directory from CVS? I'm not quite sure how this happened, but somehow a completely empty hierarchy of directories has ended up in my repository:  com/ com/companyname/ com/companyname/blah/ com/sun/ com/sun/java/ com/sun/java/jax_rpc_ri/   I think what happened was that these directories did have files in them, but then a developer realized he/she shouldn't have checked them in in the first place since these are by-products of the build process, so he/she removed the files but somehow the empty directories are left in the repository as ancient relics.  How can I remove this from CVS? The only results I seem to be able to find on google say that there shouldn't be a need to remove empty directories as CVS won't keep them around in the first place, and that the -P (prune) options to cvs update should remove them from the working directory  - which is zero help if you actually have empty directories in your repository.  A cvs remove and cvs commit doesn't seem to take care of this situation:  $ cvs remove -Rf com cvs remove: Removing com cvs remove: Removing com/companyname cvs remove: Removing com/companyname/blah cvs remove: Removing com/sun cvs remove: Removing com/sun/java cvs remove: Removing com/sun/java/jax_rpc_ri $ cvs commit com cvs commit: Examining com cvs commit: Examining com/companyname cvs commit: Examining com/companyname/blah cvs commit: Examining com/sun cvs commit: Examining com/sun/java cvs commit: Examining com/sun/java/jax_rpc_ri $ ls -l com total 24 drwxrwxr-x  2 matt matt 4096 Oct 15 14:38 CVS drwxrwxr-x  9 matt matt 4096 Oct 15 14:38 companyname drwxrwxr-x  4 matt matt 4096 Oct 15 14:38 sun   It's still there!  Does SVN have this weird behavior too? Why is the console window closing immediately once displayed my output? What is JavaScript's highest integer value that a number can go to without losing precision? Plugin or brush for transforming a photo to a fractal in gimp? Folks,  I've been looking all over for a plugin or brush that will help me take a photo and reduce it to that 'electric look' (or fractal?) that i'm seeing in various places. I'd vastly prefer one for Gimp.  Does anyone know how these are being done? I'm seening references to fractalius for photoshop, but what about gimp?  Examples: Details on the Origin of Sting I'm in Belgium (french part) and I cannot find the proper keyboard layout in Settings > Region and Languages > Input Sources.  the closest I found is the french (AZERTY) one but for the symbols such as ! and _ it's not the same keys...  what can I do to solve it ?  Thank you. Is the set of all unitary matrices in $M_2(\mathbb{C})$ is compact? I can show that as determinant map is continuous so unitary matrices are closed but how to show they are bounded?   Please help. Let $G = (\mathbb{C} - \{0\}, \cdot)$, a subgroup $U = \{x+yi \mid x^2 + y^2 = 1\}$. Use the Fundamental Theorem to show that $G/(\mathbb{R}_{&gt; 0},\cdot)$ is isomorphic to $U$ where $\mathbb{R}_{&gt; 0}$ denotes the positive reals.  I am struggling to find the correct mapping from $G$ to $U$ that results in the the kernel being the nonnegative reals under multiplication. I'm hoping to get help with this mapping then I can show it is a homomorphism and onto and can use the Fundamental Theorem. Recently, I accidentally deleted a partition off of my external hard disk. I had a copy of Minitool Power Data Recovery left over when the same drive had become RAW about a year ago. When I selected lost partition recovery, it immediately identified my deleted partition and allowed me to access and recover the files that were there.  My question is this. Is there any way to change the deleted partition back to NTFS without having to have a drive that you need to recover the files to and then move them back after formatting, as I don’t have any space left on either the computer or on my other external hard drive, so that I don’t need to buy a new one. The files on the disk were really important.  I am using Windows 7 Home Premium.  I appreciate any help in solving this crisis. I've just started using matlab-prettifier.    Since the line \begin{lstlisting}[style=Matlab-editor] is a lot to type, I created my own environment:  \newenvironment{myMP}      {\begin{samepage}\begin{lstlisting}[style=Matlab-editor]}      {\end{lstlisting}\end{samepage}}   I've used this syntax many times before, but in this case it doesn't work.  Is there any reason why I can't enclose the lstlisting inside my own one?  Here's sample code, illustrating the problem.  \documentclass{minimal} \usepackage[framed]{matlab-prettifier}%For matlab code \newenvironment{myMP}      {\begin{samepage} \begin{lstlisting}[style=Matlab-editor]}      {\end{lstlisting} \end{samepage}} \begin{document} \begin{myMP} matlab word \end{myMP} \end{document}   When I run this with pdflatex it returns a *, indicating that the environment wasn't closed properly.  Thanks! Israel visa stamp issue I am an Indian national living in London. I need to travel to Israel for work. I will need to apply for a visa but I have been told that it will be stamped in my passport. I have read that Israel knows of the problems travellers face in other Arab countries so they issue a paper visa but the embassy in London told me that it will be stamped in. I travel often in Middle East for work and I do not want any issues in the future. Please advise.  Thanks. Why won't SparseArray let me store values with the head List? Integrate : $\int \frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}dx$ $$\int \frac{x^2}{(x\cos x -\sin x)(x\sin x +\cos x)}\ dx$$   My approach :   Dividing the denominator by $\cos^2x$ we get $\dfrac{x^2\sec^2x }{(x -\tan x)(x\tan x +1)}$ then  $$\int \frac{x^2\sec^2x}{x^2\tan x -x\tan^2x+x-\tan x}\ dx=\int \frac{x^2(1+\tan^2x)}{x^2\tan x -x\tan^2x+x-\tan x}dx$$  But I am not getting any relation between numerator and denominator so that I will take any substitution and solve further please suggest whether it is correct and how to proceed in this. Thanks. Why don't websites immediately display their text these days? I've noticed that recently many websites are slow to display their text. Usually, the background, images and so on are going to be loaded, but no text. After some time the text starts appearing here and there (not always all of it at the same time).  It basically works the opposite as it used to, when the text was displayed first, then the images and the rest was loading afterwards. What new technology is creating this issue? Any idea?  Note that I'm on a slow connection, which probably accentuates the problem.  See below for an example - everything's loaded but it takes a few more seconds before the text is finally displayed: examples:         Gift (German) = poison   poisson (French) = fish   embarazada (Spanish) = pregnant   sauce (Spanish) = willow   triviale (Italian) = vulgar   parentes (Portuguese) = relatives   slim (Dutch) = smart I use this program in Windows that's one-box and searches all of my drives. By default it lists all files, everywhere, in a single list. Is there a Linux graphical utility that does this? "Stack Overflow" showing up on hamburger menu for all sites to link to /questions Why does it say "Stack Overflow" instead of the site name? If $f(1)=1$, then is it true that $f(n)=n$ for all $n \in \mathbb{N}\cup\{0\}$. What is the relationship between a chi squared test and test of equal proportions? Suppose that I have three populations with four, mutually exclusive characteristics.  I take random samples from each population and construct a crosstab or frequency table for the characteristics that I am measuring.  Am I correct in saying that:   If I wanted to test whether there is any relationship between the populations and the characteristics (e.g. whether one population has a higher frequency of one of the characteristics), I should run a chi-squared test and see whether the result is significant. If the chi-squared test is significant, it only shows me that there is some relationship between the populations and characteristics, but not how they are related. Furthermore, not all of the characteristics need to be related to the population.  For example, if the different populations have significantly different distributions of characteristics A and B, but not of C and D, then the chi-squared test may still come back as significant. If I wanted to measure whether or not a specific characteristic is affected by the population, then I can run a test for equal proportions (I have seen this called a z-test, or as prop.test() in R) on just that characteristic.   In other words, is it appropriate to use the prop.test() to more accurately determine the nature of a relationship between two sets of categories when the chi-squared test says that there is a significant relationship?