MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Base function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88166] Re: [mg88131] Base function
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Sun, 27 Apr 2008 04:57:00 -0400 (EDT)
  • References: <200804260741.DAA08453@smc.vnet.net>

haitomi wrote:

>Dear All,
>
>
>
>((1*12 + 4)*11 + 4)*10 + 4
>
>1804
>
>I need help with a function find the Calander "base"
>
>Cbase[1804,{12,11,10}]
>
>out put will be
>{1,4,4,4}
>
>Thanks All,
>Tomi
>  
>
Here is a somewhat inscrutable piece of code to do this:

Cbase[n_, base_] := Reverse@Rest[FoldList[QuotientRemainder[First[#1], 
#2] &, {n}, Append[Reverse@base, n]]][[All, 2]]

In[69]:= Cbase[1804, {12, 11, 10}]

Out[69]= {1,4,4,4}

Carl Woll
Wolfram Research


  • Prev by Date: financial chart with volumes
  • Next by Date: Change integral variables
  • Previous by thread: Base function
  • Next by thread: Re: Base function