Post History
C (gcc), 37 bytes f(n,p){while(++p*p<n);return p*p==n;} Try it online! The solution is based on the simple fact that: $$\forall n \in \mathbb{N}, n \text{ is a perfect square} \Longleftrig...
Answer
#3: Post edited
- # [C (gcc)](https://gcc.gnu.org), 37 bytes
- ``` C
- f(n,p){while(++p*p<n);return p*p==n;}
- ```
[Try it online!](https://tio.run/##dY1NDoIwEIXXcIpJDUkrYGArVG9gPAAbUlppggXboiTI2WsxRlfOYv7y3vtYemHMbaRi3dhwKI1tZL9rD05glQxkfrSy4ziOh@1QKlJobketwF@UqmJxUlm41lLhey8bEs5hMGj/ExidKvuEM9eCMwvmNtaaVwqR4qdI/9RHFgai14BXwgQUssKPkkKe@S2OJwIe9s2KmhUXGe9NYEpAYN/SnMARkNUjR7AHJOrO8Hf2Ei7uBQ)
- # [C (gcc)](https://gcc.gnu.org), 37 bytes
- ``` C
- f(n,p){while(++p*p<n);return p*p==n;}
- ```
- [Try it online!](https://tio.run/##dY1NDoIwEIXXcIpJDUkrYGArVG9gPAAbUlppggXboiTI2WsxRlfOYv7y3vtYemHMbaRi3dhwKI1tZL9rD05glQxkfrSy4ziOh@1QKlJobketwF@UqmJxUlm41lLhey8bEs5hMGj/ExidKvuEM9eCMwvmNtaaVwqR4qdI/9RHFgai14BXwgQUssKPkkKe@S2OJwIe9s2KmhUXGe9NYEpAYN/SnMARkNUjR7AHJOrO8Hf2Ei7uBQ)
- The solution is based on the simple fact that:
- $$\forall n \in \mathbb{N}, n \text{ is a perfect square} \Longleftrightarrow \exists p \in \mathbb{N}, p \le n \text{ / } p^2=n$$
#2: Post edited
# [C (GCC)](https://gcc.gnu.org), 37 bytes- ``` C
- f(n,p){while(++p*p<n);return p*p==n;}
- ```
- [Try it online!](https://tio.run/##dY1NDoIwEIXXcIpJDUkrYGArVG9gPAAbUlppggXboiTI2WsxRlfOYv7y3vtYemHMbaRi3dhwKI1tZL9rD05glQxkfrSy4ziOh@1QKlJobketwF@UqmJxUlm41lLhey8bEs5hMGj/ExidKvuEM9eCMwvmNtaaVwqR4qdI/9RHFgai14BXwgQUssKPkkKe@S2OJwIe9s2KmhUXGe9NYEpAYN/SnMARkNUjR7AHJOrO8Hf2Ei7uBQ)
- # [C (gcc)](https://gcc.gnu.org), 37 bytes
- ``` C
- f(n,p){while(++p*p<n);return p*p==n;}
- ```
- [Try it online!](https://tio.run/##dY1NDoIwEIXXcIpJDUkrYGArVG9gPAAbUlppggXboiTI2WsxRlfOYv7y3vtYemHMbaRi3dhwKI1tZL9rD05glQxkfrSy4ziOh@1QKlJobketwF@UqmJxUlm41lLhey8bEs5hMGj/ExidKvuEM9eCMwvmNtaaVwqR4qdI/9RHFgai14BXwgQUssKPkkKe@S2OJwIe9s2KmhUXGe9NYEpAYN/SnMARkNUjR7AHJOrO8Hf2Ei7uBQ)
#1: Initial revision
# [C (GCC)](https://gcc.gnu.org), 37 bytes ``` C f(n,p){while(++p*p<n);return p*p==n;} ``` [Try it online!](https://tio.run/##dY1NDoIwEIXXcIpJDUkrYGArVG9gPAAbUlppggXboiTI2WsxRlfOYv7y3vtYemHMbaRi3dhwKI1tZL9rD05glQxkfrSy4ziOh@1QKlJobketwF@UqmJxUlm41lLhey8bEs5hMGj/ExidKvuEM9eCMwvmNtaaVwqR4qdI/9RHFgai14BXwgQUssKPkkKe@S2OJwIe9s2KmhUXGe9NYEpAYN/SnMARkNUjR7AHJOrO8Hf2Ei7uBQ)