We changed our privacy policy. Read more.

New answers tagged


As indicated in the comments by gnasher729, you have made a mistake in your logic. Your logic is as follows: Input A: Input != "N" B: Input != "Y" A∨B (OR) Y TRUE FALSE TRUE N FALSE TRUE TRUE Anything Else TRUE TRUE TRUE The logic you want: Input A: Input != "N" B: Input != "Y" A∧B (AND) Y TRUE FALSE FALSE N ...


Given a non-negative integer $x$, let $|x|$ denote the number of ones in the binary representation of $x$. You can prove the claim by induction on $n$. The base case $n=0$ is trivially true. Consider then $n>0$. During the first iteration, the algorithm prints $n$ stars. The number $x$ of stars printed by the other iterations is exactly the number of ...

Top 50 recent answers are included