ITPEC FE Subject B October 2025 Question 5
ITPEC FE Subject B October 2025 — Question 5 of 20
Math & Numbers — Filling in a prime-number printing procedure by identifying where to set isPrime ← false and where to increment the found-primes counter.
The program uses a while (count ≤ N) loop to find the first N primes. For each candidate number, it checks divisibility by all integers from 2 up to √number.
- •Blank A (inside
if (number mod i = 0)): When a divisor is found, the number is not prime, so we setisPrime ← false, then exit the for loop. - •Blank B (inside
if (isPrime = true)): The number passed all checks — it is prime, so we incrementcount ← count + 1to track how many primes have been found.
Answer: c) — A: isPrime ← false, B: count ← count + 1
Why not others:
- a) count ← count + 1 in A would increment the counter when a divisor is found — the opposite of correct
- b) count ← count + i in A is nonsensical — adds the loop variable to the counter
- d) count ← count + i in B would add arbitrary values instead of incrementing by 1
Key rule: In a prime-checking loop, finding a divisor means not prime → set a flag. Incrementing the prime counter happens only after confirming primality.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.