Message Boards Message Boards

[GiF] Your age as a continued fraction

Posted 8 years ago

Your age as a continued fraction is given by the function CFage. It computes the difference between a birth date and the current time. Then this period is measured in years and transformed into a continued fraction. One can also give dates as integer lists right down to minutes and seconds. The number of terms is optional.

CFage[birthdate:(_String|_DateObject|{_Integer,___}),terms_:11]:=
    Dynamic[
       Fold[#2+1/#1&,
         MapAt[
          ToString,
              Take[
                 ContinuedFraction[
                   DateDifference[birthdate,Now]/Quantity@"yr"],
              UpTo[terms]]/.{a__,b_,1}:>{a,b+1}//Reverse,1]]//OutputForm,
    UpdateInterval->.5]

Let's take Einstein birthday as an example:

enter image description here

The function CFage will work with such DateObject or it's String analog:

enter image description here

POSTED BY: Bill Gosper
Posted 8 years ago
POSTED BY: Brad Klee
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract