If the predicate a+b = even is true, the prove the following loop is true

while (a >= 0 and a <= 100) {

a = a + 3;

b = b -1;

}

while (a >= 0 and a <= 100) {

a = a + 3;

b = b -1;

}

while (a >= 0 and a <= 100) {

a = a + 3;

b = b -1;

}

Tutors, please sign in to answer this question.

Meredith, NH

If a + b is even, then either both a and b are even or both are odd.

a could be written 2n or 2n+1, 2n-1 (even or odd, odd)

b could be written 2k or 2k+1, 2k-1 (even or odd, odd)

Substitute the even/odd representations in for a and b:

Even case:

a = 2n+3 = 2n+2+1 = 2(n+1) +1 which is odd

b = 2k-1 which is odd

Odd case:

a = (2n+1)+3 = 2n+4 = 2(n+2) which is even

b = (2k+1)-1 = 2k which is even

As the loop continues to add 3 to a each iteration it will eventually reach >=100 and run its course.

If a starts as any negative integer, it will not run.

I hope this helps.

Elliott L.

Ph.D. Math Tutor, High School and Early College Subjects

New York, NY

4.9
(275 ratings)

Gilant P.

Miss Gil: Cares & Gets Results - Regents, SAT & NYS ELA & Math Exams

Jamaica, NY

4.8
(1403 ratings)

Jason L.

Top scoring professional SAT and ACT tutor; Practicing Attorney

Livingston, NJ

5.0
(8 ratings)

- Discrete Mathematics 139
- Algebra 1 3038
- Math 6771
- Algebra 2 2689
- Number Theory 21
- Geometry 1371
- Prealgebra 141
- Precalculus 1206
- Calculus 1704
- Trigonometry 1130

Find a tutor fast. Get the app.

Are you a tutor? Get the app for tutors

© 2005 - 2016 WyzAnt, Inc. - All Rights Reserved