Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikkukreja/ee525daee751de4520e6 to your computer and use it in GitHub Desktop.
Save kartikkukreja/ee525daee751de4520e6 to your computer and use it in GitHub Desktop.
Solution permutation with a generative pattern
void print_sequence(int multiple, int decrement, int N) {
if (2 * multiple - decrement > N) {
printf("%d ", multiple - decrement);
return;
}
print_sequence(2 * multiple, decrement + multiple, N);
print_sequence(2 * multiple, decrement, N);
}
void print_sequence(int N) {
print_sequence(1, 0, N);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment