Advertisement
nguyenhappy92

Tìm k sao cho S(k)<n

Oct 9th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. // Tinh k sao cho 1+2+...+k sao cho S(k)<n
  2. // Khai bao thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. int n;
  9. scanf("%d",&n);
  10. int s=0;
  11. int a;
  12. for(int i=0;i<n;i++)
  13. {
  14. s=s+i;
  15. if(s<n)
  16. {
  17. a=i;
  18. }
  19. }
  20. printf("%d",a);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement