Skip to content

Instantly share code, notes, and snippets.

@squirrel532
Created March 7, 2017 16:19
Show Gist options
  • Save squirrel532/c8986a8dfdbea2343abec8a61dcf6ef7 to your computer and use it in GitHub Desktop.
Save squirrel532/c8986a8dfdbea2343abec8a61dcf6ef7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
/*
This function, rec will prints all number between va and vb
in diminishing order.
rec(1, 5) and rec(5, 1) give same output.
*/
int rec(int va, int vb) {
(va > vb) && printf("%d\n", va);
(vb >= va) && printf("%d\n", vb);
return va != vb && rec(va - (va>vb), vb - (vb > va));
}
int main(int argc, char const* argv[])
{
rec(5, 1);
rec(1, 5);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment