https://github.com/BuckRogers1965/Examples/blob/master/Math/additiveSeries/additiveSeries.c
#include <stdio.h> int main () { int i, j, n, x; for (x=1; x<20; x++) { printf("for additive series of size %d\n", x); for (i = 1, j = 0, n =1 ; n<10; n++, i+=x ){ j+=i; printf("%d %d %d %d \n", n, i, j, (x*n*n-(x-2)*n)/2); } printf("\n\n"); } }
Output: for additive series of size 1 1 1 1 1 2 2 3 3 3 3 6 6 4 4 10 10 5 5 15 15 6 6 21 21 7 7 28 28 8 8 36 36 9 9 45 45 for additive series of size 2 1 1 1 1 2 3 4 4 3 5 9 9 4 7 16 16 5 9 25 25 6 11 36 36 7 13 49 49 8 15 64 64 9 17 81 81 for additive series of size 3 1 1 1 1 2 4 5 5 3 7 12 12 4 10 22 22 5 13 35 35 6 16 51 51 7 19 70 70 8 22 92 92 9 25 117 117 for additive series of size 4 1 1 1 1 2 5 6 6 3 9 15 15 4 13 28 28 5 17 45 45 6 21 66 66 7 25 91 91 8 29 120 120 9 33 153 153 for additive series of size 5 1 1 1 1 2 6 7 7 3 11 18 18 4 16 34 34 5 21 55 55 6 26 81 81 7 31 112 112 8 36 148 148 9 41 189 189 for additive series of size 6 1 1 1 1 2 7 8 8 3 13 21 21 4 19 40 40 5 25 65 65 6 31 96 96 7 37 133 133 8 43 176 176 9 49 225 225 for additive series of size 7 1 1 1 1 2 8 9 9 3 15 24 24 4 22 46 46 5 29 75 75 6 36 111 111 7 43 154 154 8 50 204 204 9 57 261 261 for additive series of size 8 1 1 1 1 2 9 10 10 3 17 27 27 4 25 52 52 5 33 85 85 6 41 126 126 7 49 175 175 8 57 232 232 9 65 297 297 for additive series of size 9 1 1 1 1 2 10 11 11 3 19 30 30 4 28 58 58 5 37 95 95 6 46 141 141 7 55 196 196 8 64 260 260 9 73 333 333 for additive series of size 10 1 1 1 1 2 11 12 12 3 21 33 33 4 31 64 64 5 41 105 105 6 51 156 156 7 61 217 217 8 71 288 288 9 81 369 369 for additive series of size 11 1 1 1 1 2 12 13 13 3 23 36 36 4 34 70 70 5 45 115 115 6 56 171 171 7 67 238 238 8 78 316 316 9 89 405 405 for additive series of size 12 1 1 1 1 2 13 14 14 3 25 39 39 4 37 76 76 5 49 125 125 6 61 186 186 7 73 259 259 8 85 344 344 9 97 441 441 for additive series of size 13 1 1 1 1 2 14 15 15 3 27 42 42 4 40 82 82 5 53 135 135 6 66 201 201 7 79 280 280 8 92 372 372 9 105 477 477 for additive series of size 14 1 1 1 1 2 15 16 16 3 29 45 45 4 43 88 88 5 57 145 145 6 71 216 216 7 85 301 301 8 99 400 400 9 113 513 513 for additive series of size 15 1 1 1 1 2 16 17 17 3 31 48 48 4 46 94 94 5 61 155 155 6 76 231 231 7 91 322 322 8 106 428 428 9 121 549 549 for additive series of size 16 1 1 1 1 2 17 18 18 3 33 51 51 4 49 100 100 5 65 165 165 6 81 246 246 7 97 343 343 8 113 456 456 9 129 585 585 for additive series of size 17 1 1 1 1 2 18 19 19 3 35 54 54 4 52 106 106 5 69 175 175 6 86 261 261 7 103 364 364 8 120 484 484 9 137 621 621 for additive series of size 18 1 1 1 1 2 19 20 20 3 37 57 57 4 55 112 112 5 73 185 185 6 91 276 276 7 109 385 385 8 127 512 512 9 145 657 657 for additive series of size 19 1 1 1 1 2 20 21 21 3 39 60 60 4 58 118 118 5 77 195 195 6 96 291 291 7 115 406 406 8 134 540 540 9 153 693 693
No comments:
Post a Comment