Count number of ways for remaining number n - i remaining parts " parts - 1" , and for all part varying from ' nextPart ' to ' n '
for ( $ i = $ nextPart ; $ i <= $ n ; $ i ++ ) $ ans += countWaysUtil ( $ n - $ i , $ parts - 1 , $ i ) ;