You are not logged in.
Pages: 1
I have to write a function f(n) that has the result the lowest number higher or equal to n that is dividable by 4.
For ex:
f(24) = 24, f(25)=28 ...
The only solution that I can think of is:
f(n) = [n/4+1]*4.
But it doesnt work for n numbers that are dividable by 4.
Thank you and sorry if I've made some mistake, I'm new here!
Offline
You're very close, just leave out the 1 and use the ceiling function (I can't tell from your post if you were using the ceiling or floor function):
Last edited by TheDude (2008-02-26 05:48:48)
Wrap it in bacon
Offline
Pages: 1