Rename some variables and add parameter R to morrison primality test.