All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Another Man's Floor (Posted on 2005-11-23) Difficulty: 4 of 5
Let a, b, and m be positive whole numbers. Required is a fast algorithm for evaluating Σk=0..m floor(ka/b), floor(x) being the greatest integer that does not exceed the real number x.

See The Solution Submitted by Richard    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Jump Start | Comment 7 of 11 |

 Let a=5, b=17, m=23. Then

 

Sum_{0<=k<=23}floor(5*k/17) + Sum_{0<=l<=6}ceiling(17*l/5)=6*(23+1)=144,

 

where ceiling(x) is the least integer not less than x (so that ceiling is like floor, but it rounds non-integers up instead of down).

 

 

 

Edited on December 29, 2005, 9:27 pm
  Posted by Richard on 2005-12-29 21:16:02

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information