There are $n^2$ squares disposed in a bigger n by n square, like a grid. Something like [this][1]  The question is: how many rectangles can be formed using those squares? I saw this problem in a [blackpenredpen][2] (youtube maths channel) and decided to try and figure it out by myself, as I had an idea. The idea I had was to calculate the number of possible diagonals that could be made from picking any two squares in the grid, since one diagonal is all it takes to define a rectangle. It made sense to divide by 2, since $n \choose 2$ would yield 2 diagonals for each rectangle. So, I tried $\frac{n \choose 2}{2}$, but the results I got didn't match with the correct ones (I know the correct result, as it can be obtained by other methods, like the ones presented in the [video][2]). I had really high hopes for this idea and was disppointed when I got an incorrect result. I toyed and fiddled a little with the results I got, but to no avail. I did find out that for $n=8$ the difference between the result I got and the correct one was $7!$, which I found suspicious.  Can anyone help me figure out why my reasoning is not yielding the correct results? If I wasn't clear or there is something I should do better, please point it out. Thank you! I am enjoying this site.
I have come across numerous questions where I am given the picture such as the above one been asked "how many rectangles are there?". I have even come across some slightly different images that instead of rectangles you are supposed to find the number of triangles. Well, I was thinking whether there is any formula or strategy that is used to solve these problems without having to manually count every shape.  Help would be appreciated.  Thank you :)
Additional horizontal space when the last line of an environment is full I have created an environment env which just adds a \medskip and some text (say "Blablabla") after the text inside \begin{env} ... \end{env}. The problem is that if the last line is full, then I get an additional horizontal space between the text and "Blablabla".  Here is an MWE:  \documentclass{article} \newenvironment{env}{ ENVIRONMENT:\par }{ \medskip \par\noindent Blablabla }  \begin{document}  \section*{First case: the last line is not full}  \begin{env} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla malesuada porta tortor non vestibulum. Vivamus vel tincidunt purus. Curabitur quam arcu, suscipit sed diam sed, ornare efficitur felis. Duis at arcu iaculis, viverra ligula sit amet, hendrerit eros. Proin finibus venenatis sollicitudin. Nunc ullamcorper sem ut lacinia posuere. Integer pulvinar nulla lorem, ut pulvinar ipsum egestas at. Duis quam ipsum, posuere ac pulvinar vitae, auctor non leo. \end{env}  \section*{Seconde case: the last line is full}  \begin{env} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque suscipit vitae neque eu gravida. Quisque et enim quam. Integer elementum diam a ex laoreet, ac egestas lacus volutpat. Nunc ullamcorper non urna tincidunt ultrices. Etiam eu ultricies diam. Proin mollis, nunc sit amet volutpat varius, ipsum tellus bibendum nulla, in eleifend lacus felis pellentesque nisl. Phasellus laoreet, libero quis auctor congue, nulla nulla aliquam metus, in hendrerit arcu justo quis tortor. Nunc nec nisi euismod, consectetur tellus nec, suscipit libero.  \end{env}  \end{document} Does commutativity imply associativity? I'm asking this because I was trying to think of structures that are commutative but non-associative but couldn't come up with any. Are there any such examples?  NOTE: I wasn't sure how to tag this so feel free to retag it. What kinds of compensation can I get from Deutsche Bahn for canceled and late trains? Can't format my usb drive. I have already tried with mkdosfs and gparted I have a MicroSD card in a USB adapter (which plugs into a USB port on my machine, and acts like a USB flash drive). I was using Unetbootin to make this a bootable USB flash drive with Kubuntu. But I needed to cancel while it was working. So I killed the Unetbootin process from the console.  Since then, I can't format the MicroSD or delete the folder that Kubuntu made. I have also tried mkdosfs, with no success. I can't mount the drive anymore either? What can I do to make this drive usable again?  Trying to create a new partition table in GParted, as described in Eliah Kagan's answer, does not work. It fails with the error message "imposible crear tabla de particiones" ("unable to create a partition table"). What are the different endings in Dishonored? In Dishonored the game as I am escaping the prison, I got a prompt that warned me:      Using stealth and nonlethal approach has benefits. Fewer rats and   weepers, some people react favorably, and the final outcome is not as   dark.   What are all the different endings? And how much chaos yields them? And what is the optimal ending? Are you allowed to stack Divine Smite and Eldritch Smite on the same attack? Complement of maximal multiplicative set is a prime ideal Let $R$ be a commutative ring with identity. I've been trying to prove the following:     If $S \subset R$ is a maximal multiplicative set, then $R \setminus S$ is a prime ideal of $R$.   I have spent some time in it, but nothing is coming to my mind. Any idea/solution will be appreciated. Fractional Laplacian on the torus Open Safari / Google Chrome developer tools programmatically from JavaScript What is the relation between normal extension and separable extension? What is the relation between normal extension and separable extension? Let F be the algebraic extension of K, if F is a separable extension of K,if and only if F is a normal extension of K? is this correct? Is there a better way to do optional function parameters in JavaScript? How do I find the angle between two vectors? I have 3 points on my screen:  a = a point which is (c.x, 0) makes a line pointing straight up b = a user input touch, can be anywhere on the screen c = a moving object         a _______.________ |      |       | |      |       |  |   b  |       | |  .   |       | |   \  |       | |    \ |       |  |     \|       | |      | c     | |______._______|   I have drawn some lines so that you can see the vectors.  I want to be able to get the angle between a and b. I have tried this, but it doesn't work, does anyone know what I'm doing wrong?:  //v1 moving object float boxX = this.mScene.getLastChild().getX();  float boxY = this.mScene.getLastChild().getY();  //v2 user touch float touchX = pSceneTouchEvent.getX(); float touchY = pSceneTouchEvent.getY();       //v3 top of screen float topX = boxX; final float topY = 0;  float dotProd = (touchX * topX) + (touchY * topY);  float sqrtBox = (touchX * touchX) + (touchY * touchY); float sqrtTouch = (topX * topX) + (topY * topY);  double totalSqrt = sqrtBox * sqrtTouch; double theta = Math.acos(dotProd / Math.sqrt(totalSqrt));   The answer I usually get is between 0 and 1. How do I fix this so that I get the angle in degrees? prevent php classes from being extends Is there any way to tell Google to display the updated title instead of displaying the old blog title in search results? As a matter of optimization, a few weeks ago I modified the way the titles of my blog posts are displayed (I made a change also in the title of the blog). Then I used the Google Webmaster Tools to re-index the old pages and update titles. Immediately I could update the titles and posts appear correctly on Google.  The problem is that now the titles of posts began to appear incorrectly in the search, using the old blog title. Some posts continue to display the updated title, but many recent posts show the old title.  I've tried re-index the pages with Google Webmaster Tools, but the titles remain unchanged in the search results.  Is there any way to "force" Google to display the correct titles? SQL Index Performance - ASC vs DESC I a chat discussion it was suggested that \hspace*{\fill} (with a space before it to allow for a line break) was sufficient to always get the text following aligned to the right. And indeed, it is aligned to the right.    However, in one case it is inserting an additional line  break where one should not be required as illustrated by the last example here.  I want the text bumped to the next line if and only if (iff ) there is no room:    If I remove the space before the \hspace*{\fill}, there are cases (second and third) where a new line should have been inserted but is not:    Related Question:      I have tried the suggestions at the related question and:   Martin Scharrer's suggestion of using \hbox{}\hfill results in the text being on the left for the last case. Herbert's \When macro exhibits a similar problem for the last case. Thorsten Donig's \signed macro does yield the correct number of lines, but portions of the file name for the middle two cases show up on the second line when they easily fit in the first line.     Notes:  I believe that this is unrelated to the problem, as I was able to reproduce the problem without it.  But, am mentioning it here in case it causes an issue with the proposed solution.  I am using \texttt for the file name. This resulted in an additional complication which I initially thought was the cause of the problem.  So, my actual use case is commented out below and it incorporates a solution from        Code:  \documentclass{article} \usepackage[paperwidth=7.0cm,showframe]{geometry} \usepackage{xcolor} \usepackage{xparse}   \newcommand*{\FillLine}[2]{% \noindent\parbox{\linewidth}{%     \raggedright     File:~#2 % &lt;-- Need space here     %Space before \hspace* allows for a break before it     \hspace*{\fill}\texttt{\small CONFIDENTIAL}%  }% }  %\newcommand*{\EnableHyphenationInTexttt}{\hyphenchar\font=45\relax} % %\newcommand*{\FillLine}[2]{% %    \noindent\parbox{\linewidth}{% %       \raggedright %       File:~\texttt{\EnableHyphenationInTexttt#2} % &lt;-- Need space here %       %Space before \hspace* allows for a break before it %       \hspace*{\fill}\texttt{\small CONFIDENTIAL}%  %    }% %}  \begin{document} \FillLine{Name}{Value}  \bigskip \FillLine{Name}{A-Long-Value}  \bigskip \FillLine{Name}{iiiiiii-iiiii-iiiiiii}  \bigskip \FillLine{Name}{Some-Really-Really-Long-Value} \end{document} This question is about why we have a universal speed limit (the speed of light in vacuum). Is there a more fundamental law that tells us why this is? I'm not asking why the speed limit is equal to $c$ and not something else, but why there is a limit at all. EDIT: Answers like &quot;if it was not..&quot; and answers explaining the consequences of having or not having a speed limit are not--in my opinion-- giving an answer to whether there is a more fundamental way to derive it from a law to explain this limit. JavaScript: client-side vs. server-side validation Which is better to do client side or server side validation?  In our situation we are using    jQuery and MVC.   JSON data to pass between our View and Controller.     A lot of the validation I do is validating data as users enter it. For example I use the the keypress event to prevent letters in a text box, set a max number of characters and that a number is with in a range.   I guess the better question would be, Are there any benefits to doing server side validation over client side?    Awesome answers everyone. The website that we have is password protected and for a small user base(&lt;50). If they are not running JavaScript we will send ninjas. But if we were designing a site for everyone one I'd agree to do validation on both sides. Are repository updates secure?  As a bear of little brain from the developer side, I cannot understand why the repository list is http://security.ubuntu.com and the other http(unsecured) sites listed in /etc/apt/sources.list.  Without a certificate chain match this appears as "ask any responder for a list of packages to update" instead of "ask the ubuntu.com site..."  Can any network choose to spoof the update sites, and is this a common practice to provide a locally cached and vetted copy? Does the integral $\int_{1}^{\infty} \sin(x\log x) \,\mathrm{d}x$ converge?