My Math Forum Function problem

 Algebra Pre-Algebra and Basic Algebra Math Forum

 February 26th, 2008, 08:13 AM #1 Newbie   Joined: Feb 2008 Posts: 1 Thanks: 0 Function problem 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!
February 26th, 2008, 11:47 AM   #2
Global Moderator

Joined: Nov 2006
From: UTC -5

Posts: 16,046
Thanks: 938

Math Focus: Number theory, computational mathematics, combinatorics, FOM, symbolic logic, TCS, algorithms
Re: Function problem

Terminology: you need to find an expression for that function. The words already define the function.

Quote:
 Originally Posted by spank 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.
4[n/4] gives you the next lower one, so I think -4[-n/4] should do what you want. Check it and tweak if it's off.

 February 27th, 2008, 12:52 PM #3 Global Moderator   Joined: Dec 2006 Posts: 20,274 Thanks: 1959 If n is a non-negative integer, f(n) = 4[(n + 3)/4], where [x] denotes the integer part of x.

 Tags function, problem

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post mathwiztheo Algebra 2 November 19th, 2012 03:58 AM nanalala125 Linear Algebra 1 September 19th, 2012 08:00 PM reave Algebra 1 November 4th, 2011 06:05 AM murkr Algebra 1 April 19th, 2010 05:56 PM jsucupira Algebra 2 October 15th, 2007 12:59 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top