MathGroup Archive 1995

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

Search the Archive

Mathematica Pearls

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2310] Mathematica Pearls
  • From: Don Piele <piele at cs.uwp.edu>
  • Date: Mon, 23 Oct 1995 12:44:01 -0400

Mathematica Pearls

Here are two problems that were possed in the latest issue of 
Mathematica in Education and Research - Summer 1995. The purpose of 
this problem section is to suggest small problems and collect together
interesting (and fast) ways to solve them.

The first problem is for beginnners, the second for more advanced.

1. Ordered Fractions (Source - USA Computing Olympiad, 1995)


Consider the set of all reduced rational numbers between 0 and 1 
inclusive with denominators
 less than or equal to N.

Here is the set when N = 5:

     {0, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1}

Create a function orderedFractions[N] that, given an integer N  prints 
the ordered fractions 
in order of increasing magnitude. (Know as the Farey Sequence).


orderedFractions[5]

{0, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1}


2.  sumTo[n] (Source  USA Computing Olympiad, 1995) 

    Create a function, sumTo[n], which  finds all the ways you can add 
consecutive positive integers that sum to n. Display the solution as a 
list of pairs {a,b} where a+(a+1) + (a+2) +....+ b = n.
    
    Here is the solution for n=10000.
    
    sumTo[10000]
    
    {{18, 142},{297, 328},{388, 412},{1998, 2002}}


D. Piele
piele at cs.uwp.edu



  • Prev by Date: Re: Converting Mathematica graphics to EPS and PS files
  • Next by Date: Re: Bug in interpretation of mma Series[] command?
  • Previous by thread: Mthm f Win 2.2.1: Lines missing at page breaks when printing notebooks
  • Next by thread: Help with factoring out an exponential