-3
$\begingroup$

"The first two numbers that are both squares and triangles are 1 and 36. Find the next one and, if possible, the one after that. Can you figure out an efficient way to find triangular–square numbers? Do you think that there are infinitely many?"

Thanks.

$\endgroup$

closed as off-topic by user296602, Shailesh, user99914, Leucippus, Xander Henderson Oct 15 '17 at 3:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Community, Shailesh, Community, Leucippus, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ What have you tried? Do you know the formula for the triangular numbers? Set it equal to $k^2$. Note that I added the diophantine equations tag. A spreadsheet will find the next couple easily. Just compute the triangular numbers, take the square root, and search by eye for an integer. I don't think that will help the general case. $\endgroup$ – Ross Millikan Oct 15 '17 at 2:00
  • $\begingroup$ I would do it by trying... $\endgroup$ – mdave16 Oct 15 '17 at 2:00
  • 4
    $\begingroup$ Can you find a less informative title? $\endgroup$ – Andreas Blass Oct 15 '17 at 2:03
  • 2
    $\begingroup$ @AndreasBlass It could have been the ever-so-popular "I have a math question." $\endgroup$ – user296602 Oct 15 '17 at 2:30
  • 1
    $\begingroup$ This is a duplicate of this question $\endgroup$ – Ross Millikan Oct 15 '17 at 4:08
1
$\begingroup$

$${t_n} = \sum\limits_{k = 1}^n k = 1 + 2 + 3 + \cdots + n = \frac{{n\left( {n + 1} \right)}}{2} = n-th{\text{ triangular number}}$$ $${s_m} = {\text{m-th square number}} = {m^2}$$ $${s_m} = {t_n} \Rightarrow \frac{1}{2}n\left( {n + 1} \right) = {m^2}$$ $$\frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} = \frac{1}{2}\left( {{n^2} + n + \frac{1}{4}} \right) = \frac{1}{2}\left( {{n^2} + n} \right) + \frac{1}{8}$$ $$\frac{1}{2}n\left( {n + 1} \right) = \frac{1}{2}\left( {{n^2} + n} \right) = \frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} - \frac{1}{8} = {m^2}$$ $$\frac{1}{2}{\left( {n + \frac{1}{2}} \right)^2} - {m^2} = \frac{1}{8}$$ $$4{\left( {n + \frac{1}{2}} \right)^2} - 8{m^2} = 1$$ $$2 \cdot \left( {n + \frac{1}{2}} \right) \cdot 2\left( {n + \frac{1}{2}} \right) - 8{m^2} = 1$$ $${\left( {2n + 1} \right)^2} - 8{m^2} = 1$$ $${\left( {2n + 1} \right)^2} - 2 \cdot {\left( {2m} \right)^2} = 1$$ $$\boxed{w \equiv 2n + 1}$$ $$\boxed{z \equiv 2m}$$ $$\boxed{{w^2} - 2{z^2} = 1}$$

Finding numbers that satisfy the last equation above isn't all that simple... so I found the first numbers that are both triangular and square using python

import pandas as pd
import numpy as np
triangular_and_square = []
for n in np.arange(1,10000):
    w = 2*n + 1
    for m in np.arange(1,10000):
        z = 2*m
        if w*w - 2*z*z - 1 == 0:
            triangular_and_square.append([m*m,m,n])
output_dataframe = pd.DataFrame(triangular_and_square,
                                 columns = ["Square (m-squared) + Triangular","m","n"], 
                                 index = [1,2,3,4,5,6])

print(output_dataframe)

Code output

$$\begin{array}{*{20}{c}} & {{\rm{Square (}}{m^2}){\rm{ and Triangular}}}&& m&& n& \\ \hline & 1&& 1&& 1& \\ & {36}&& 6&& 8& \\ & {1225}&& {35}&& {49}& \\ & {41616}&& {204}&& {288}& \\ & {1413721}&& {1189}&& {1681}& \\ & {48024900}&& {6930}&& {9800}& \end{array}$$

$\endgroup$
  • $\begingroup$ Your code has both triangular_and_square and triangluar_and_square. Please could you check it for typos and make sure it is what you intend? $\endgroup$ – Rosie F Oct 15 '17 at 18:19
  • $\begingroup$ Oh wow. Didn't even notice I did that. triangluar_and_square = [] <---- a list triangluar_and_square.append([m*m,m,n]) <--- adding values to the list triangular_and_square <---- a dataframe triangular_and_square = pd.DataFrame(triangluar_and_square.... <---- I used the list _triangluar_and_square to create the dataframe triangular_and_square. I should've used different names for the dataframe and the list. The old version worked fine., but I changed the name of the dataframe to avoid confusion. Sorry about my sloppy original answer. $\endgroup$ – Dave Rosenman Oct 16 '17 at 19:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.