id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

bryce.hulett@hotmail.com > lazyCaterer
prev  |  next  |  chance

The Lazy Caterer’s Sequence: Formally also known as the central polygonal numbers, it describes the maximum number of pieces (or bounded/unbounded regions) of a circle (a pancake or pizza is usually used to describe the situation) that can be made with a given number of straight cuts. For example, three cuts across a pancake will produce six pieces if the cuts all meet at a common point, but seven if they do not. The maximum number p of pieces that can be created with a given number of cuts n, where n ≥ 0, is given by the formula (n^2 + n + 2) / 2. Return this sequence as a List given some number of terms.


lazyCaterer(1) → [1]
lazyCaterer(6) → [1, 2, 4, 7, 11, 16]
lazyCaterer(4) → [1, 2, 4, 7]

...Save, Compile, Run (ctrl-enter)

public List lazyCaterer(int terms){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy