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

High School Challenge
- 50 Problems
- 98 Finishers
- Times 2 - START HERE
- Add two numbers
- Laws of motion 3
- Laws of motion 6
- Force and Motion 2
- Force and Motion 3
- Velocity Conversion
- Potential energy calculation
- An Ohm's Law Calculator
- Electrical Diode Current Calculation
- Resistance of a light bulb
- Calculate Parallel Resistance
- Current through resistor
- Energy Conversion 2
- Mass Conversion 1
- Convert from Fahrenheit to Celsius
- Return area of square
- Area Conversion 1
- Create times-tables
- Triangle Numbers
- How long do each of the stages of the rocket take to burn?
- Finding Perfect Squares
- Magnitude of Balancing Force
- Mechanical Advantage of a Gear Train
- Calculate load on arm 1
- Find the mass of a rod
- Find the force required to support a lever
- Coefficient of Kinetic friction
- Calculate the acceleration of a crate
- Coefficient of Sliding Friction
- Coefficient of Static friction
- Linear Motion 1
- Linear Motion 2
- Linear Motion 3
- Linear Motion 4
- Linear Motion 5
- Linear Motion 6
- Linear Motion 7
- Basic Mathematics 1
- Basic Mathematics 2
- Basic Mathematics 3
- Basic Mathematics 4
- Basic Mathematics 5
- Basic Mathematics 6
- Basic Mathematics 7
- Basic Mathematics 8
- Resistance of a robot
- Voltage in a lamp
- Resistance in a circuit
- Calculate supply voltage and total current
Problem Recent Solvers19245
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!