03 For
03 For
Sum of series
Write C programs that will calculate the sum of each series up to its n terms.
1. 1+2+3+4+5…
Sample input Sample output
5 15
8 36
2. 1+3+5+7+9+…
Sample input Sample output
5 25
8 64
3. 2 + 4 + 6 + 8 + 10 + …
Sample input Sample output
5 30
8 72
4. 3 + 6 + 9 + 12 + 15 + …
Sample input Sample output
5 45
8 108
5. 1 + 2 + 4 + 8 + 16 + …
Sample input Sample output
5 31
8 255
6. 5 + 10 + 20 + 40 + 80 + …
Sample input Sample output
5 155
8 1275
7. 10 + 30 + 90 + 270 + 810 + …
Sample input Sample output
5 1210
8 32800
8. 12 + 22 + 32 + 42 + 52 + …
Sample input Sample output
5 55
8 204
9. 1.2 + 2.3 + 3.4 + 4.5 + 5.6 + …
Sample input Sample output
5 70
8 240
10. 2.5 + 4.8 + 8.11 + 16.14 + 32.17 + …
Sample input Sample output
5 898
8 11778
Miscellaneous
1. Write a C program that will take as input an integer, and calculate its factorial.
Sample input Sample output
5 120
8 40320
2. Write a C program that will take as input two integers n and r, and calculate nPr.
Sample input Sample output
62 30
83 336
3. Write a C program that will take as input two integers a and n, and calculate an. (You
cannot use math.h)
Sample input Sample output
23 8
35 243
4. Write a C program that will find out if an input integer is prime or not.
Sample input Sample output
23 Prime
27 Not prime