Problem 44399. 二乗になっている数を見つけよう
ある数のベクトルが与えられた場合、そのベクトルの要素の一つが他の要素の二乗であれば true を返し、それ以外の場合は false を返すようなコードを書いてみましょう。
例:
入力が a = [2 3 4] のとき、 出力 b は true になります。
2の2乗は4であり、ベクトル内に2と4の両方が含まれているため、出力は true になります。
- (英語版) Problem 23. Finding Perfect Squares https://www.mathworks.com/matlabcentral/cody/problems/23-finding-perfect-squares/solutions/1330236
Solution Stats
Problem Comments
-
2 Comments
David Verrelli
on 11 Nov 2017
This appears to be duplicating an error in the original Problem: according to the problem specification, having an input of [1] should yield a result of "false", as there is no OTHER element to compare the 1 to! You can easily fix this inconsistency by either --- changing your problem specification (mention that you can compare to all vector elements, not just the 'other' elements) or --- by changing the correct result to "false" in your Test Suite.
David Verrelli
on 11 Nov 2017
Please check comments made about the original Problem to avoid duplicating errors or inconsistencies.
Solution Comments
Show commentsGroup

Operations
- 32 Problems
- 14 Finishers
- modular arithmetic
- Sum the 'edge' values of a matrix
- Subtract integers and add doubles
- Multiplication
- Let's get back to school, and create multiplication tables
- Make an N-dimensional Multiplication Table
- Mmm! Multi-dimensional Matrix Multiplication
- Accurate Division
- Number of even divisors of a given number
- Raise a polynomial to a power
- Array ex-OR
- Airline Ticket Mod7 Checksum
- Determinant without using det()
- Calculate the hypotenuse of a right triangle without using ^ and sqrt ()
- Calculate sin(x) without sin(x)
- Calculate cosine without cos(x)
- Negative without '-'
- calculate PI without using pi function
- Church Encoding
- Concatenated roots
- Product of Each Column
- Perl 1: push
- Vector push
- Vector pop
- Shuffle
- Please check the last row
- Converting Decimal to Binary
- Temperature Conversion Utility
- Temperature Conversion Utility (Strings)
- Calculate the sum of two polynomials
- Moving average (variable kernel length)
- Weighted average
Problem Recent Solvers326
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!