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 commentsGroup

CodeCrunch 1
- 11 Problems
- 10 Finishers
- Calculate the height of an object dropped from the sky
- Compute the missing quantity among P, V, T for an ideal gas
- Remove duplicated triangles
- An Ohm's Law Calculator
- Laws of motion 6
- Find the longest sequence of 1's in a binary sequence.
- Determine whether a vector is monotonically increasing
- Calculate the probability that at least two people in a group share the same birthday.
- Finding Perfect Squares
- The Goldbach Conjecture
- Pangrams!
Problem Recent Solvers19746
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!