We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Fundamentals
- Restaurant
- Discussions
Restaurant
Restaurant
Sort by
recency
|
260 Discussions
|
Please Login in order to post a comment
I haven't seen my approach in the comments yet and figured it may help out anyone else trying to wrap their head around it.
Alternative to the GCD approach (well documented below), I mentally wanted to find the largest square that was divisible by both l and b. It's not the most efficient, but it's how I saw the solution:
Python3
def restaurant(l, b):
Can Someone Find the Error in my Function
int restaurant(int l, int b) { if(0 == b % l ) { return b/l; } else { float frac = (float)b / (float)l ; int i = 1; while( (frac != (int)(frac)) ) { frac +=(float)b / (float)l; i++; } return (int)(i)*(int)(frac); } }