Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6. int numero= 1;
  7. //int resultado;
  8.  
  9. while(numero <= 64) {
  10.  
  11. printf("%dn", numero);
  12. numero++;
  13.  
  14. }
  15. return 0;
  16.  
  17.  
  18. }
  19.  
  20. #include <stdio.h>
  21.  
  22. int main(void) {
  23. int numero = 1;
  24. int resultado = 0;
  25. while (numero < 65) resultado += numero++;
  26. printf("%dn", resultado);
  27. }
  28.  
  29. int resultado = 0;
  30. for (int numero = 1; numero < 65; numero++) resultado += numero;
  31. printf("%dn", resultado);
  32.  
  33. 1 + 2 + 3 + ... + (n-1) + n
  34. n + (n-1) + (n-2) + ... + 2 + 1
  35. -------------------------------------------
  36. (n+1) + (n+1) + (n+1) + ... + (n+1) + (n+1)
  37.  
  38. 2S = n*(n+1)
  39.  
  40. S = n*(n+1)/2
  41.  
  42. ( n*(n+1) )/2
  43.  
  44. #include <stdio.h>
  45.  
  46. int main()
  47. {
  48. int n = 64;
  49. printf("%dn", ( n*(n+1) )/2);
  50.  
  51. return 0;
  52. }
  53.  
  54. #include <stdio.h>
  55. int main(){
  56. int numero = 0;
  57. int soma = 0;
  58.  
  59. while(numero < 5) {
  60. numero++;
  61. soma = soma + numero;
  62. printf("%dn", soma);
  63. }
  64. }
Add Comment
Please, Sign In to add comment