Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Michael Haufe (TNO)" Newsgroups: comp.lang.javascript Subject: Re: Javascript Math problem Date: Fri, 27 Apr 2012 17:30:23 -0700 (PDT) Organization: http://groups.google.com Lines: 18 Message-ID: <6507721.320.1335573024044.JavaMail.geo-discussion-forums@ynen8> References: NNTP-Posting-Host: 108.215.220.26 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1335573114 14588 127.0.0.1 (28 Apr 2012 00:31:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 28 Apr 2012 00:31:54 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=108.215.220.26; posting-account=hYRygAoAAABkmvJVmPilz9Q1TOjgPQAq User-Agent: G2/1.0 Xref: csiph.com comp.lang.javascript:13653 On Friday, April 27, 2012 5:41:55 PM UTC-5, Tom wrote: > Hi, I was wondering if someone could help me with math puzzle. I need a > function that will give me the number of times an integer is divisible > by 3, but I can't use the round function. In other words, > if I sent the value of 6, it would return 2 since 6/3 = 2. 9/3 = 3 etc. > For numbers that are not evenly divisible, 5/3 would need to return 1, > 7/3 would return 2 etc, basically scrap the decimal numbers. But like I > said it can't use round. > > I was thinking that possibly it would use some combination of the > division and modulus operators (/,%), but I haven't been able to figure > it out yet. > > Can anyone think of anything? Thx Simple enough for the mathematically inclined: function f(n){ return (n-(n%3))/3 }