fork download
  1. #include <stdio.h>
  2.  
  3. int is_odd(unsigned n);
  4. int is_even(unsigned n);
  5.  
  6. int is_even(unsigned n)
  7. {
  8. return n == 0 ? 1 : is_odd(n-1);
  9. }
  10.  
  11. int is_odd(unsigned n)
  12. {
  13. return n == 0 ? 0 : (n == 1 ? 1 : is_even(n-1));
  14. }
  15.  
  16. int main(void)
  17. {
  18. unsigned num;
  19.  
  20. num = 17;
  21. printf("%u is %s\n", num, is_even(num) ? "even" : "odd");
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
17 is odd