I suspect you need to start $toggle reversed for odd values (or for even values, though you note that you verified against the two even cases). Though, I would have expected that particular mistake to lead to negative values (but you don't show most of the code so I didn't go much further in looking). The numbers are supposed to be f(...)**$P where f() is positive (and monotonic), so, yes, odd values of $P should give you results between the results for $P-1 and $P+1, not like the results you posted.
Sorry for the wrapping.
You might want to put the big tables into READMORE tags so that they don't impact the rendering of the whole thread (though that should only happen for people who have code wrapping badly configured).