Skip to content

armanatz/banana-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

The Banana Challenge

Description

A number of people (let's call it N) are stranded on an deserted island with a huge pile of bananas and a monkey. At night, each person does the following without the others knowing:

  1. They take one N'th (e.g. if N=3, one third) of the bananas in the pile and hides them
  2. The division leaves one banana left over, which is given to the monkey.

In the morning, they divide the remaining bananas among themselves and this time the split is even. There's nothing left over for the monkey.

Your task: Given the number of people (N), how many bananas were in the pile to begin with (lowest possible number)?

Formal inputs/outputs

Input

Single number: N, which is the number of people. This number is a whole number that is greater than or equal to 2.

Output

Single number: the number of bananas in the original pile.

Sample input/output

Input:

5

Output:

3121

About

A short challenge given by KualaLumpurJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published