• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. def sum1(n):
3.     suma=0
4.     for i in range(1,n+1):
5.         suma+=i
6.     return suma
7. def sum2(n):
8.     suma=0
9.     for i in range(1,n+1):
10.         suma+=2*i-1
11.     return suma
12. def sum3(n):
13.     suma=0
14.     for i in range(1,n+1):
15.         suma+=1/(i**2+i)
16.     return suma
17. def sum4(n,x):
18.     suma=0
19.     for i in range(1,n+1):
20.         suma+=x**(1/(i+1))
21.     return suma
22. def sum5(n):
23.     suma=0
24.     for i in range(0,n):
25.         suma+=(-2)**i
26.     return suma
27. def sum6(n):
28.     suma=0
29.     for i in range(1,n+1):
30.         suma+=1/i**3
31.     return suma
32. def sum7(n):
33.     suma=0
34.     for i in range(1,n+1):
35.         suma+=(-1)**i
36.     return suma
37. def ilo1(n):
38.     ilo=0
39.     for i in range(1,n+1):
40.         ilo*=i-1
41.     return ilo
42. def ilo2(n):
43.     ilo=0
44.     for i in range(1,n+1):
45.         ilo=i**(-i)
46.     return ilo
47. def ilo3(n):
48.     ilo=0
49.     for i in range(1,n+1):
50.         ilo=1/i**3
51.         return ilo
52.
53. print(sum1(3))
54. print(sum2(4))
55. print(round(sum3(5),2))
56. print(sum4(1,9))
57. print(sum5(5))
58. print(round(sum6(6),2))
59. print(sum7(7))
60. print(ilo1(4))
61. print(ilo2(2))
62. print(ilo3(7))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top