exerciseJan212008

exerciseJan212008 - In computer science, for improved...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP202 Instructor: Ladan Mahabadi January 21, 2008 1. Sum of a geometric series: Prompt the user to enter a real value between 1 and -1. Do not proceed unless the entered value is valid. Then prompt the user for the number of iterations and compute the sum of the geometric series (for that number of iterations) using the following given equation:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2. sin(x), cos(x) After learning to compute e and π using the Maclaurin series, write a program that receives x and number of iterations from the user and outputs sin(x) and cos(x).
Background image of page 2
3. Exponentiation:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: In computer science, for improved efficiency, exponentiation is done by repeatedly squaring the base. For instance to compute 3 5 , one computes 3(3 2 ) 2 and similarly 16 200 = (((16 2 ) 2 ) 2 ) 25 = (((16 2 ) 2 ) 2 ). (((16 2 ) 2 ) 2 ) 24 = (((16 2 ) 2 ) 2 ). ((((((16 2 ) 2 ) 2 ) 2 ) 2 ) 2 ) 3 = (((16 2 ) 2 ) 2 ). (((((16 2 ) 2 ) 2 ) 2 ) 2 ) 2 . (((((16 2 ) 2 ) 2 ) 2 ) 2 ) 2 .( (((((16 2 ) 2 ) 2 ) 2 ) 2 ) 2 ) 2 4. Primality: Write a program that receives an integer and outputs whether or not the entered value is a prime....
View Full Document

Page1 / 4

exerciseJan212008 - In computer science, for improved...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online