The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

In the code fragment on the right, start and end are integer values and $prime(x)$ is a function that returns true if $x$ is a prime number and $false$ otherwise. At the end of the loop:

i := 0; j := 0; k := 0;
for (m := start; m <= end; m := m+1){
k := k + m;
if (prime(m)){
i := i + m;
j := j + m;
  1. $k < i+j$
  2. $k = i+j$
  3. $k > i+j$
  4. Depends on $start$ and $end$
in Algorithms by Veteran (100k points) | 55 views

1 Answer

0 votes

B. $k = i + j$

Whatever be the value of m, the value added to k is also added to exactly one of i and j.

by Boss (35k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,092 questions
55,239 answers
85,992 users