[BOJ 9488] The n Days of Christmas

View as PDF

Submit solution

Points: 2
Time limit: 2.0s
Memory limit: 128M

Problem type
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

On the first day of Christmas, my true love gave to me, a partridge in a pear tree.</p> </blockquote>

Great. I wanted an iPad.

On the second day of Christmas, my true love gave to me, two turtle doves, and a partridge in a pear tree.

OK, now I have 4 birds: two turtle doves and a partridge today, and a partridge from yesterday. My cats are going crazy.

On the third day of Christmas, my true love gave to me, three french hens, two turtle doves, and a partridge in a pear tree.

What's with the birds? I now have ten of them, and no place to put them (except insidethe cats). How long can my true love keep this up?

Given a number of days of Christmas, figure out the total number of gifts I'm going to receive.

입력 형식

There will be several test cases in the input. Each test case will consist of a single integer n (1≤n≤1,000,000), on its own line. The input will end with a line with a single 0.

출력 형식

For each test case, output a single integer, indicating the number of gifts I’m going to receive, in total. Output no spaces, and do not separate answers with blank lines.

예제 입력

1
2
3
0

예제 출력

1
4
10

Comments

There are no comments at the moment.