// // Title: Concepts of Programming Languages // Number: CAS CS 320 // Semester: Fall 2012 // Class Time: TR 12:30-2:00 // Instructor: Hongwei Xi (hwxiATcsDOTbuDOTedu) // Teaching Fellow: Alex Ren (arenATcsDOTbuDOTedu) // (* // // Assignment #8 // Due Tuesday, April 9, 2013 at 11:59pm // Total points: 50 // *) (* ****** ****** *) (* // // Points: 20 // Assgn5Ex1: 10 points The following is a well-known series: ln 2 = 1 - 1/2 + 1/3 - 1/4 + ... Please implement a stream consisting of all the partial sums of this series. Then compute an accurate approximation to ln2 by using Euler's transform. *) (* 15 points *) fun genAssgn5Ex1Stream (): stream double (* 05 points *) fun ln2 (): double // Use Euler's transform to speed up convergence (* ****** ****** *) (* // // Points: 30 // A natural number \$n\$ is a Ramanujan number if there exist two distinct pairs of natural numbers (i1,j1) and (i2,j2) such that \$n=i1^3+j1^3=i2^3+j2^3\$. For instance, \$1729\$ is a Ramanujan number as \$1729=1^3+12^3=9^3+10^3\$. Please construct a stream of all Ramanujan numbers and then use it to find the first twenty Ramanujan numbers. *) fun genAllRamanujanNumbers (): stream (int) fun fprintRamanujanNumbers (out: FILEref, n: int): void // printing out n Ramanujan numbers // end of [fprintRamanujanNumbers] (* ****** ****** *) (* end of [assignment8.dats] *)