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 Solvers19208
Suggested Problems
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1856 Solvers
-
Increment a number, given its digits
658 Solvers
-
747 Solvers
-
Rounding off numbers to n decimals
4771 Solvers
-
Find out sum and carry of Binary adder
1533 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!