CSE 142 Lecture Notes - Lecture 10: Prime Number

83 views6 pages
Verified Note

Document Summary

October (cid:799)(cid:805)th, (cid:800)(cid:798)(cid:799)(cid:806) - if-else state(cid:289)e(cid:290)ts, & su(cid:289)(cid:289)atio(cid:290) 4 // system. out. println(number + " has" + numfactors(number) + " 13 // computes and returns the number of factors of the given integer. 15 // int num - the integer whose factors are to be computed. 17 // for loop up to num. 19 for ( int i = 1; i <= num; i++) { 20 // check if numb / i has a remainder. 21 if (num % i == 0) { 22 // % means modulum or modulus, which is the remainder in division. 24 // remember, to use an equal sign, must be 2 "==" 25 // this is because 1 "=" means assignment. 26 // if not, add 1 to a count. 29 // if so, don"t add 1. 34 // determines whether a given integer is prime. 36 // int num - the number to test. 43 // determines whether a given integer is even or odd.

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