CSCI 10 Lecture Notes - Lecture 6: Divisor

44 views2 pages

Document Summary

All homework, slides and code examples are on michaeljbannister. com. Problem 2: write a program that can determine if a given number is prime. 0 is not prime: write a program that prints all primes below 1000. For (int f = 2; f < n; f++) { Count++: write a program that prints the first 1000 primes. Problem 3: write a program to print a given number in binary. (for now we will settle with printing it backwards) 1 / 2 = 0 for (int k = n; k > 0; k= k/ 2 or k/=2) cout << k % 2; Problem 4: write a program to compute the greatest common divisor of two numbers. (there are many ways to do this! Strive for the simplest!) int n, m = 0; cout << prompt cin >> for (int i = n; i > n) *refactoring re-designing a working program to make it better.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents