Assertions
Category: Assertions
Author: Marty Stepp and Benson Limketkai
Book Chapter: 5.5
Problem: Assertions
For each of the five points labeled by comments, identify each of the following assertions as being either always true, never true or sometimes true / sometimes false. public static int assertions(int n) { int x = 2; <span class="assertionpoint">// Point A while (x < n) { <span class="assertionpoint">// Point B if (n % x == 0) { n = n / x; x = 2; <span class="assertionpoint">// Point C } else { x++; <span class="assertionpoint">// Point D } } <span class="assertionpoint">// Point E return n; }
1) x > 2
2) x < n
3) n % x == 0