You are viewing a single comment's thread. Return to all comments →
Nice... can be simplified a touch more
public static int stepPerms(int n) { int[] arr = { 1, 2, 4 }; for (int i = 4; i <= n; i++) { arr[(i - 1) % 3] = arr.Sum(); } return arr[(n - 1) % 3]; }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Davis' Staircase
You are viewing a single comment's thread. Return to all comments →
Nice... can be simplified a touch more