problem 21... somewhat less trivial plus more R