fork download
  1. n <- 5000
  2. m <- 2 * n - 1
  3. d <- dist((1:n) ^ 3)
  4. r <- rle(sort(d[duplicated(d)]))
  5.  
  6. for (x in r$value[r$length >= 4]) {
  7. i <- which(d == x)
  8. b <- ceiling((m - sqrt(m ^ 2 - 8 * i)) / 2)
  9. a <- n + i - (m - b) * b / 2
  10. cat(x, ": ", toString(sprintf("(%d, %d)", a, b)), "\n", sep = "")
  11. }
Success #stdin #stdout 2.13s 323312KB
stdin
Standard input is empty
stdout
1412774811: (1134, 357), (1155, 504), (1246, 805), (2115, 2004), (4746, 4725)