Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. long long expr(long long a, long long b)
  7. {
  8. if (b==0) return 1;
  9. else
  10. {
  11. if (b%2==0)
  12. {
  13. long long x = expr(a, b/2);
  14. return x*x;
  15. }
  16. else
  17. {
  18. long long x = expr(a, b/2);
  19. return x*x*a;
  20. }
  21. }
  22. }
  23.  
  24.  
  25. long long exp(long long a, long long b)
  26. {
  27. long long x=1;
  28. for(int i=0; i<b; i++)
  29. x = x*a;
  30. return x;
  31. }
  32.  
  33.  
  34. int main()
  35. {
  36. for(int i=2; i<100; i++)
  37. for(int j=1; j<10000; j++)
  38. if (exp(i,j)!=expr(i,j)) cout << i << ' ' << j << '\n';
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement