SalmaYasser

Untitled

Nov 7th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. bool fun(int n)
  2. {
  3.     int x = (int)(sqrt(n));
  4.  
  5.     if (x*(x+1)==n)
  6.        
  7.         return true;
  8.     else
  9.         return false;
  10. }
  11.  
  12.  
  13. int main()
  14. {
  15.     int a = 6 , b = 20;
  16.     int res = 0;
  17.     for (int i = a ; i <= b ; i++)
  18.         if (fun(i))
  19.             res++;
  20.     return res;
  21.      
  22.    
  23. }
Add Comment
Please, Sign In to add comment