In the book, Elements of programming CASE ANALYSIS has been listed as one of the approaches to solve a problem.
As an example, the book states that
for all n , n^3 mod 9 would either be 0,1,8 and even splits this problem into following cases where n belongs to the following category
- n = 3m
- n = 3m + 1
- n = 3m +2
Based on the way that this has been glossed over in the book, it seems like a trivial concept. But i couldn't establish the relation between n^3 and all the three cases which are listed above. They seems to be (at least to my understanding) the numbers which are similar to n = num mod 3
But how does it relate to proving n^3 mod 9 is 0,1 and 8 and how these three cases would suffice to prove the problem statement