Number of Managers

A company is arranged in a heirarchical structure, with a layer of workers at the bottom. Each worker is managed by a manager. Consequently, each manager is managed by another manager until there is a company "boss". Each manager is restricted to managing, at most, x workers. For a company of size y calculate the number of managers required (including the boss)

Function should take two inputs. Eg non-golfed definition: calc_num_managers(num_workers, num_workers_per_manager)

You can assume that the number of workers per manager will be greater than 1.

Examples:

• A company with 0 workers needs 0 managers
• If the company has 4 workers, and each manager can manage 8 workers, then there is 1 manager.
• If the company has 4 workers, and each manager can manage 4 workers, then you need 1 manager
• If the company has 12 workers, and each manager can manage 8 workers, then there are 3 managers:
• "two team leaders and a boss" - This needs to be expanded on. Jul 27, 2017 at 10:28
• Hello and Welcome to PPCG. You should consider posting in the sandbox first. Your examples make no sense. I´d say 7 or 5 managers for the last example, depending on wether the managers are workers too or not. Jul 27, 2017 at 10:33
• At first I thought, you were asking for ceiling(y/x) but now I'm confused.. Jul 27, 2017 at 10:39
• Still not clear, why 3 managers are needed.. here Jul 27, 2017 at 11:02
• The second manager is the one boss in Wheat Wizard's organogram. Jul 27, 2017 at 19:41

C, C++, Java, C#, D : 73 69 bytes

-4 bytes thanks to Zacharý

Due to the similarities between theses languages, this answer works for each.
Maybe it works in processing too, but i can't test

int c(int w,int p){int r=0;do{w=(w+p-1)/p;r+=w;}while(w>1);return r;}


Here is an optimized version in D : 62 bytes thanks to Zacharý

T c(T)(T w,T p){T r;do{w=(w+p-1)/p;r+=w;}while(w>1);return r;}


T here is a type for template metaprogramming. This function is callable with c(4,8);

• Amazing, one code for 3 langs)) Jul 29, 2017 at 20:17
• @ЕвгенийНовиков 4* languages. Just edited to test for C :) Jul 29, 2017 at 20:19
• And how about includes ? codegolf.meta.stackexchange.com/questions/7515/… Jul 29, 2017 at 20:20
• @ЕвгенийНовиков Well, the question just says to have a function, not a full program Jul 29, 2017 at 20:22
• I think this works in D (wow, actually a decent D answer) and Processing as well. Jul 30, 2017 at 20:19

Jelly, 14 bytes

Ṃ÷⁴Ċ0Ṃ’$?µÐĿḊS  Try it online! JavaScript, 46 43 bytes If scheme isn't solvable, there will be stack exeeded error -3 bytes ceil trick inspired by Cows quack f=(w,m)=>(r=0|(w+m-1)/m,r>1&&(r+=f(r,m)),r) //test ;[[0,1],[4,8],[4,4],[12,8],[8,3],[10,3]]//0;1;1;3;4;7 .map(e=>console.log("w="+e[0]+" m="+e[1]+" result="+f(e[0],e[1]))) Requirements w count of workers, non-negative integer m count of max workers per manager, positive integer • I believe |1 is shorter than Math.ceil Jul 29, 2017 at 19:29 • @Cowsquack (19/10)|1 is 1, but ceil 2 Jul 29, 2017 at 19:31 Perl 5, 44 + 1 (-n) = 45bytes $t=<>;$m+=$_=1+int$_/$t while($_>1);say$m|\$_


Try it online!

Husk, 7 bytes

ΣtU¡(⌈/


Try it online!

Repeatedly (¡) takes the ceiling (⌈) of the division (/) of the number of workers by the number of workers per manager and sums (Σ) all the unique results (U).