# COSC 117 Lab 2 - Salisbury University

COSC 117 LAB 2 Dr. Joe Anderson September 6, 2017 MODULUS OPERATOR Modulus operator: % Performs division of two numbers and returns only the remainder Ex: 11 % 5 == 1

10 % 5 == 0 23 % 3 == 2 Common usage: to test if a number is even or odd! If n is even, then n % 2 == 0 If n is odd, then n % 2 == 1 LAB: 3N + 1 PROBLEM Given: a positive integer n If n is even, divide it by 2

If n is odd, multiply it by 3 and add 1 Stop when n is 1, otherwise, repeat Ex: Start with 3 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 Your tasks: Ask user for a positive int Perform 3N + 1 operation, until it reaches 1, and print each step to the terminal

## Recently Viewed Presentations

• What is a vector? A vector is an entity with 2 properties: Direction. Magnitude (the length) Vectors are equal if: Same direction & magnitude???
• Martin 1 Supported Housing 1000 units of 55+ housing 400 units of Supported Housing Support contracts c.£3m pa Self-funded TST 1 ECH Fernleigh 38 sale 10 shared owner 32 rented The Paddocks 11 shared owner 33 rented Marketing strategy &...
• Part 2: Unit 2 Performance Matrix ... just not called "functional assessment" An "ABC" analysis is a functional assessment Mager & Pipe, 1970, flowchart to determine whether a performance problem was a training problem or a consequence problem Petrock, 1978,...
• Capable for integration with Moodle platform Scenario Teacher creates a Turnitin assignment in BUMoodle. The assignment is created in Turnitin's server automatically as well. Student submits the assignment (e.g. MSWord file) via BU Moodle. Turnitin performs the plagiarism checking and...
• Description of Curriculum:Target Population. Currently, the target population is fifth graders. This is a result of studies presenting an escalation in suicide attempts in sixth grade students.
• ECON 360, Economics of GamblingCollege of CharlestonMaymester 2010, Dr. Walker. ... (APC 1999) National Opinion Research Center (NORC 1999) National Research Council's Pathological Gambling: A Critical Review (1999) Examples of major studies.
• STRESS & STRESS MANAGEMENT So what is STRESS anyway? Stress is a mental and physical response of our bodies to change in our lives! ... Type Type A - stress prone aggressive /hostile attitudes & behavior Type B - stress...
• A Works Cited list is a list, alphabetized by author, of all of the outside sources you actually use in your essay. Most professors require a Works Cited list at the end of the essay. Keep the list on note...