Created
February 20, 2017 23:21
-
-
Save fedeisas/cb0df94f7ff37870d30022a75ec4e7cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Define a function pieces so that pieces(N) tells you the maximum number of pieces into which you can cut a piece of paper with N cuts. | |
% You can see an illustration of this problem at the top of this step. | |
% If you’d like to take this problem further, think about the 3-dimensional case. Into how many pieces can you cut a wooden block with N saw cuts? | |
% Taking it even further: What is the general problem in n dimensions? | |
-module(howManyPieces). | |
-export([howManyPieces/1]). | |
howManyPieces(0) -> | |
1; | |
howManyPieces(X) when X > 0 -> | |
X + howManyPieces(X - 1). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment