Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int f(int n)
  5. {
  6. if (n<=9)
  7. {
  8. return 0;
  9. }
  10. if (n%4==0)
  11. {
  12. return 0;
  13. }
  14. return 1+f(n-3);
  15. }
  16. int main()
  17. {int n;
  18. cout<<"n= ";cin>>n;
  19. cout<<"f("<<n<<")= "<<f(n);
  20. return 0;
  21. }
  22.  
  23.  
  24.  
  25. #include <iostream>
  26.  
  27. using namespace std;
  28. int f(int n)
  29. {
  30. if(n<=0)
  31. {
  32. return -1;
  33. }
  34. if(n%2==0)
  35. {
  36. return 0;
  37. }
  38. if(n%3==0)
  39. {
  40. return 0;
  41. }
  42. return 1+f(n-10);
  43. }
  44. int main()
  45. {int n;
  46. cout <<"n= ";cin>>n;
  47. cout <<"f("<<n<<")="<<f(n);
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement