Skip to content

Instantly share code, notes, and snippets.

@tobigithub
Last active July 6, 2016 22:22
Show Gist options
  • Save tobigithub/895ea1c14aa9a6452aca to your computer and use it in GitHub Desktop.
Save tobigithub/895ea1c14aa9a6452aca to your computer and use it in GitHub Desktop.
# Kind Sequence
# https://oeis.org/A262602
# https://en.wikipedia.org/wiki/Kind_sequence
# 1, 1, 3, 5, 7, 9, 13, 19, 27, 39, 57, 83, 119, 171, 247, 357, 515, 743, 1073, 1549, 2235, 3225, 4655, 6719, 9697,
# 13995, 20199, 29153, 42075, 60725, 87643, 126493, 182563, 263487, 380283, 548851, 792139, 1143269, 1650045,
# 2381459, 3437085, 4960637, 7159533
# The sequence seems simply odd first, but then in a gentle
# and kind way escapes to higher numbers
# Tobias Kind (2015)
library(memoise)
Kind <- memoise(function(n) {
if (n < 2) return(1)
Kind(n - 7) + Kind(n - 4) + Kind(n - 1)
})
# Print Kind Sequence flat
for (i in 1:30) {cat(Kind(i)," ");};
# Print Kind Sequence
for (i in 1:40) {cat(i, Kind(i),"\n");};
#END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment