is_kaprekar <- function(n) {
  
  nch <- unlist(strsplit(format(n^2, scientific = FALSE), ""))
  len <- length(nch)

  if(len < 2) {
    return(FALSE)
  }

  for(i in 1:(len - 1)) {
    first <- as.integer(paste0(nch[1:i], collapse = ""))
    second <- as.integer(paste0(nch[(i+1):length(nch)], collapse = ""))
    if(first + second == n && (second > 0)) {
      cat(first, "+", second, "=", n,"\n")
      return(TRUE)
    }
  }