S
S
Seigfried2021-01-15 07:19:35
Mathematics
Seigfried, 2021-01-15 07:19:35

How to find squares from a given series of integers (for example, 4, 16, 25, etc.)?

What is the search algorithm here?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-01-15
@sergiks

Take the square root on the forehead and see if the number is an integer.
If the range is limited, you can pre-compile a list of all the squares in this range and search among them - this can be faster.
Here , for example, they are looking for the fastest way to determine whether a number is the square of an integer for long numbers.

S
Sumor, 2021-01-15
@Sumor

Comparing the numbers of a row with a list of squares.
The list of squares can be sequentially obtained by adding odd numbers:
1=1
1+3=4
1+3+5=9
1+3+5+7=16
, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question