The Lazy Caterer 's Problem | A C ++ program to find the solution to The Lazy Caterer 's Problem ; This function receives an integer n and returns the maximum number of pieces that can be made form pancake using n cuts ; Use the formula ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int findPieces ( int n ) { return ( n * ( n + 1 ) ) / 2 + 1 ; } int main ( ) { cout << findPieces ( 1 ) << endl ; cout << findPieces ( 2 ) << endl ; cout << findPieces ( 3 ) << endl ; cout << findPieces ( 50 ) << endl ; return 0 ; }