Problem 23. Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the numbers. Otherwise return false.
Example:
Input a = [2 3 4]
Output b is true
Output is true since 2^2 is 4 and both 2 and 4 appear on the list.
Solution Stats
Problem Comments
-
39 Comments
Show
36 older comments
Christian Schröder
on 20 Oct 2023
@Tran Up to floating point arithmetic, sqrt(a(i))^2 is the same as a(i), so you're really just testing whether the vector a is non-empty.
(Note that the failing cases are the one where the correct answer is "false", while the ones where you succeed are the ones where it is "true").
Oren
on 8 Jan 2024
Nice little problem :)
Umar
on 22 May 2024
It was very interesting
Solution Comments
Show commentsProblem Recent Solvers19152
Suggested Problems
-
649 Solvers
-
835 Solvers
-
Find the largest value in the 3D matrix
1542 Solvers
-
Circular Primes (based on Project Euler, problem 35)
564 Solvers
-
595 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!