The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1669 - File: showthread.php PHP 8.2.28 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 1669 errorHandler->error_callback
/showthread.php 915 buildtree




Brain tickler if you're bored
#1
So, I'm doing something for work where I need to do some Math/logic. It seems like a question I'd get on a CS exam. If you feel like having a crack at it, dooooo it!

So, I've got a result set and it won't all fit on one page. So, for example, I've got 12 results and I can fit 5 / page. I know only two things: the number of results and the max per page. How can I figure out how many are on a certain page given only the page number?

When you post a solution, use clear variable names like "cur_page" and "num_results", etc... You are allowed to use programming functions like ceil() and floor(). Do it as efficiently as possible. (A friend and I have figured it out 2 ways to get it on one line. Neither are particularly pretty. One uses a ternary operator, other looks like complex math equation. There has GOT to be a good way to do it. i.e. no ternary operator and in one statement.)
My Tumblr
2008 Felt F75 - Pedal Power
  Reply


Messages In This Thread

Forum Jump: