Advertisement
awsmpshk

Untitled

Mar 1st, 2020
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int del(int n) {
  6. int cnt = 0;
  7. for (int i = 2; i <= n; ++i) {
  8. if (n % i == 0) cnt++;
  9. }
  10. return cnt;
  11. }
  12.  
  13. int f(int n, int i = 0) {
  14. int cnt = del(n - i);
  15. if (del(++n) != cnt) {
  16. f(++n, ++i);
  17. }
  18. else {
  19. return n;
  20. }
  21. }
  22.  
  23. int main() {
  24. int n;
  25. cin >> n;
  26. cout << f(n) << endl;
  27. return 0;
  28. }
Advertisement
RAW Paste Data Copied
Advertisement