[Solved] CSCI1300/1310-Quiz 2

$25

File Name: CSCI1300/1310-Quiz_2.zip
File Size: 188.4 KB

SKU: [Solved] CSCI1300/1310-Quiz 2 Category: Tag:
5/5 - (1 vote)

Write a function that will take an integer, n, as a parameter and will return an integer based on one of three cases:

if the input is positive (or zero) and even: return n/2

if the input is positive odd: return 3n+1 if the input is negative return 0 This is known as the collatz iteration.

Use the header: int collatz(int n)

Example: collatz(5) would return 16, collatz(16) would return 8,

collatz(-199) would return 0

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI1300/1310-Quiz 2
$25