Neco 2025 Computer Studies Question 2
Practice objective / multiple choice question 2 from the 2025 Neco Computer Studies examination.
The following Python program is intended to compute the sum of all integers \( \le n \) that are prime and whose digit‑sum is also prime. However, it contains a logical error. Identify and correct the error, then determine the value returned by the corrected program when \( n = 30 \). Also state the asymptotic time‑complexity of the program in Big‑O notation.\n\n```python\ndef is_prime(k):\n if k < 2:\n return False\n for j in range(2, int(k**0.5) + 1):\n if k % j == 0:\n return False\n return True\n\ndef special_sum(n):\n total = 0\n for i in range(2, n): # <-- error here\n if is_prime(i):\n s = sum(int(d) for d in str(i))\n if is_prime(s):\n total += i\n return total\n```
Answer Options
About This Question
This is Neco 2025 Computer Studies Question 2. It is one of the objective questions from the 2025 Neco Computer Studies examination.
Difficulty level: Hard .
Master the Exam!
You've seen a preview, but there are thousands more questions plus AI tutor to break down complex solutions.