**ID:** UVA – 10079 – Pizza Cutting
**Difficulty :** Geometric Intuition
**Type : **Geometry.
**Description : **
- Each new line you add to the circle can be put to cut all the previous lines. ( fact )
- if the line crossed n lines then it added new n+1 slices. ( draw it to get it )
- then if p parts exist and we add new line we have p + n+1 where n is the previous no of lines existed. ( intution )
- then the recurrence formula is defined as follows p( i ) = p( i-1 ) + i;
- can’t you see it’s the arithematic sequence sum ?

**Code:**

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long N;
while((N =in.nextLong()) >=0){
long S = (N*(N+1))/2 +1;
System.out.println(S);
}
}
}

### Like this:

Like Loading...

*Related*