wave.shuffle <- function(n) {
  deck <- 1:n 
  new.deck <- c(matrix(data = deck, ncol = 2, byrow = TRUE)) 
  counter <- 1 
  
  
  while (!identical(deck, new.deck)) { 
    new.deck <- c(matrix(data = new.deck, ncol = 2, byrow = TRUE)) 
    counter <- counter + 1 
  }
  return(counter) 
}
test.values <- c(8, 24, 52, 100, 1020, 1024, 10000) 
test <- sapply(test.values, wave.shuffle) 
names(test) <- test.values 
test