ITエンジニアが仕事に対して思うこと

ITエンジニアとして働く中で感じたことを、現場の温度感そのままに言語化するブログです。設計・実装・運用のリアル、学び続ける負荷、品質とスピードのせめぎ合い、コミュニケーションの難しさなど、きれいごとだけでは語れない「仕事の実態」を整理します。誰かを責めるのではなく、なぜそうなるのかを構造で捉え、明日から少し楽に、少し強く働ける視点を提供します。新人から中堅、マネジメントまで参考に。

【動画解説】ITPEC April 2025 FE (Fundamental IT Engineer) Subject B Q5| Step-by-Step Explanation

www.youtube.com Question 5 is essentially a “reverse engineering” exercise: you are given a small amount of behavior from a function calc(x, y) and you must identify which candidate expression matches that behavior. The key clue is the test case that the sources provide, namely that calling calc(4, 9) produces the value 25. From that single input-output pair, the exam expects you to infer the intended mathematical formula and then translate that formula into a correct expression using the provided primitive pow(a, b). Start with the arithmetic meaning of the numbers 4, 9, and 25. The values 4 and 9 are perfect squares, and their square roots are integers: √4 equals 2 and √9 equals 3. If you add those square roots you get 2 + 3 = 5. Squaring that sum gives 5² = 25, which matches the required return value. This is a strong signal that the target computation is “take the square roots of x and y, add them, then square the result.” Written as a single mathematical expression, that is (√x + √y)². While there can be other expressions that coincidentally produce 25 for the single pair (4, 9), the fact that the inputs are chosen as simple squares and the output matches the square of the sum of their roots is not an accident; it is the standard pattern used in programming exams to indicate nested operations and the importance of parentheses. The next step is to express (√x + √y)² using the pow function. The definition of pow(a, b) is that it returns a raised to the power b, i.e., aᵇ. In most programming contexts, square roots are represented by raising to the power 0.5, because x0.5 is √x for nonnegative x. So √x can be represented as pow(x, 0.5) and √y can be represented as pow(y, 0.5). The sum of the square roots then becomes pow(x, 0.5) + pow(y, 0.5). Finally, squaring the entire sum means raising that whole sum to the power 2. Using pow, that outer squaring is written as pow( (something), 2 ), where “something” must be the full sum, not just one part of it. Therefore the correct structure is an outer pow whose base is the parenthesized sum of two inner pow calls, and whose exponent is 2. That produces pow(pow(x, 0.5) + pow(y, 0.5), 2). To see why the parentheses and nesting matter, consider what would happen if you squared only one of the terms or forgot to apply the outer square to the entire sum. For example, an expression like pow(x, 0.5) + pow(y, 0.5)² would treat the squaring as applying only to the second term, not to the sum, and it would not match the intended formula. Likewise, an expression like pow(x, 0.5 + pow(y, 0.5), 2) would radically change the meaning by putting the addition inside the exponent rather than in the base. The exam’s distractor options are typically designed around these common structural mistakes: squaring the wrong part, using the wrong exponent, or applying pow in the wrong nesting order. The only option that faithfully represents “square the sum of the square roots” is the one where the addition occurs first inside the base of the outer power operation. You can verify the derived expression directly with the given test case. Substitute x = 4 and y = 9. The inner calls compute pow(4, 0.5) and pow(9, 0.5), which evaluate to 2 and 3 respectively. The sum inside the outer base becomes 2 + 3 = 5. The outer call then computes pow(5, 2), which equals 25. This matches the required output, confirming that the translation from the mathematical intent to the program expression is correct. Accordingly, the correct choice is the option that exactly matches pow(pow(x, 0.5) + pow(y, 0.5), 2), which is identified as option (a). The reasoning is not merely pattern matching; it is a disciplined reconstruction: infer the formula from the observed output, represent the square roots using exponent 0.5, ensure the addition happens before the squaring by nesting and parentheses, and then confirm that the expression reproduces the provided result. This is precisely what the question is testing: not advanced mathematics, but the ability to map a specification into correct operator precedence and function nesting using a given primitive such as pow.