Assignment3

# Assignment3 - Department of Computer Science The University...

This preview shows pages 1–2. Sign up to view the full content.

Department of Computer Science The University of Hong Kong CSIS1117A Computer Programming I Assignment 3 Due Date: 23:59 Nov 1, 2009. You may assume all inputs are valid in these exercises. 1. The Fibonacci Sequence is defined by the following recurrence relation: ( ) () ( ) 0, 1 1, 2 12 fn= i f n= ifn = otherwise fn +n , −− ⎩⎭ Assuming the first two Fibonacci number is 0 and 1. Their values are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597 . .. Write a program to print the first n Fibonacci number (the output number is divided by a space). Your program should read the integer value n(n > 0) from cin . Sample run of your program (The line whose font is Times New Roman, Italic and Bold : is user input; the line whose font is Courier and Bold is output): 8 0 1 1 2 3 5 8 13 2. The Luhn algorithm is a simple checksum formula to prevent simple typo error when inputting a sequence of digits, such as credit card numbers. The algorithm works as follows: Initialize sum to 0.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 05/04/2011.

### Page1 / 2

Assignment3 - Department of Computer Science The University...

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

View Full Document
Ask a homework question - tutors are online