Some digits look (nearly) the same when turned upside-down (0, 1, 8).
Two more come in a pair, each being the other turned upside down (6,
9). The rest (2, 3, 4, 5, 7) don't look like digits when turned upside down.
Some years look the same when turned upside-down. For example, 1691
is unchanged if turned upside down. (Note that turning a year upside
down means turning the digits upside down and reverseing their order.)
Write an R function that can be used to test whether positive integers
are unchanged when turned upside-down. The function should have the
following form.
invertible =
function(n) {
...
}
Given a vector of positive integers, the function should return a vector
of logicals that indicate whether the values look the same when turned
upside-down.
Here is how the function should appear in action.
> invertible(c(1, 96, 99, 123, 1691))
[1] TRUE TRUE FALSE FALSE TRUE