Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth triangular number, we have
condition$$ n = \frac{k(k+1)}{2} \iff k^2+k-2n = 0 \iff k = \frac12 (-1 \pm \sqrt{1+8n}), $$
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is not required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth triangular number, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is not required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth triangular number, we have
$$ n = \frac{k(k+1)}{2} \iff k^2+k-2n = 0 \iff k = \frac12 (-1 \pm \sqrt{1+8n}), $$
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is not required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth triangular number, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is oddnot required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is odd required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth triangular number, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is not required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth, we have
conditioncondition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is odd required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is odd required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.
Jelly, 5 bytes
×ばつ8‘Æ2
Background
Let n be the input. If n is the kth, we have
condition
which means there will be a natural solution if and only if 1 + 8n is an odd, perfect square. Clearly, checking the parity of 1 + 8n is odd required.
How it works
×ばつ8‘Æ2 Main link. Argument: n×ばつ8 Yield 8n.
‘ Increment, yielding 8n + 1.
Æ2 Test if the result is a perfect square.