Gce Model Questions Vol1 2023 Computer Studies Question 19
Practice objective / multiple choice question 19 from the 2023 Gce Model Questions Vol1 Computer Studies examination.
The following Python function returns the sum of all numbers from 1 to *n* that are multiples of 3 or 5 but not both. ```python def f(n): total = 0 for i in range(1, n+1): if (i % 3 == 0) ^ (i % 5 == 0): # exclusive OR total += i return total ``` (a) What value does `f(20)` return? (b) Rewrite the function so that it computes the same result without using a loop, by applying arithmetic‑series formulas. (You need only give the new function body, not the full program.)
Answer Options
About This Question
This is Gce Model Questions Vol1 2023 Computer Studies Question 19. It is one of the objective questions from the 2023 Gce Model Questions Vol1 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.