# [CodeWars] Sequences and Series

Have a look at the following numbers.

`````` n | score
---+-------
1 |  50
2 |  150
3 |  300
4 |  500
5 |  750
``````

Can you find a pattern in it? If so, then write a function `getScore(n)`/`get_score(n)`/`GetScore(n)` which returns the score for any positive number `n`:

``````int getScore(1) = return 50;
int getScore(2) = return 150;
int getScore(3) = return 300;
int getScore(4) = return 500;
int getScore(5) = return 750;``````

### My Solution

 int getScore(int n) {  return n * (50 + (25 * (n – 1)));}Colored by Color Scripter cs

I found a pattern like the following.

```getScore(1) = 1 * (50 + (25 * 0))
getScore(2) = 2 * (50 + (25 * 1))
getScore(3) = 3 * (50 + (25 * 2))
getScore(4) = 4 * (50 + (25 * 3))
getScore(5) = 5 * (50 + (25 * 4))
getScore(n) = n * (50 + (25 * (n - 1)))```

### Other Solutions

 int getScore(int n) {  return 50*n*(n+1)/2;} cs
##### (this source is witten by accord75, bekor, swoopydo, szega, Ruslan_Glazkov.)

I think this is also a good idea. To solve this problem, you have to find a pattern that appears first. Then, the others are so easy.

## 글쓴이: BakJH

Student of Daedeok SW Meister Highschool, in Korea.