# ITECH1400 Fundamentals of Programming Assignment 1

Overview :-
In this assignment you will have the opportunity to test your Python skills in generating and manipulating lists. Through out the assignment you are expected to apply the principles of problem solving that we have already discussed in this course.
ITECH1400 Fundamentals of Programming Assignment 1

Timelines and Expectations
Minimum time expectation: 20 hours

Learning Outcomes Assessed
The following course learning outcomes are assessed by completing this assessment:

Knowledge:
K1. Identify and use the correct syntax of a common programming language.
K2. Recall and use typical programming constructs to design and implement simple software solutions.
K4. Explain the importance of programming style concepts documentation mnemonic names indentation.

Skills:
S1. Utilise pseudocode and/or algorithms as a major program design technique.
S2. Write and implement a solution algorithm using basic programming constructs.
S4. Describe program functionality based on analysis of given program code.

Application of knowledge and skills:
A1. Develop self-reliance and judgement in adapting algorithms to diverse contexts.
A2. Design and write program solutions to identified problems using accepted design constructs.

ASSESSMENT DETAILS

0.Introduction.
In this assignment you are required to develop software a set of functions that can be used to investigate research the un solved mathematical problem called Collatz Conjecture.

Although the problem is considered to be very difficult its formulation can be understood by a school student:

Collatz Conjecture:
Consider the following operation on an arbitrary positive integer, n, which we denote f(n):

• If the number n is even, then f(n) = n/2.
• If the number n is odd, f(n) = 3*n + 1.

Now form a sequence a Collatz sequence by performing this operation repeatedly, beginning with a positive integer n and taking the result at each step as the input at the next. You stop once you reach 1.

For example if n = 3, then the sequence will be:

[3, 10, 5, 16, 8, 4, 2, 1]

Or for n = 7 the sequence is:
[7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]

You can see that in both examples we eventually reach 1.

The Collatz Conjecture claims that this is always true, i.e., the process will eventually reach the number 1 regardless of which positive integer n is chosen initially.

Task 1. Building Collatz sequence. In this task you are required to write a Python function named

collatzSequence(n),
that takes a positive integer parameter, n, and returns a list containing the Collatz sequence for n. For example, collatzSequence(3) should return the list: [3, 10, 5, 16, 8, 4, 2, 1]

In your program you may define other auxiliary functions with arbitrary names how ever the solution function of this task should be named collatzSequence(n).

ITECH1400 Fundamentals of Programming Assignment 1

In this task you are required to write a Python function max Length that returns two integers:

• First returned value: for each integer k, 1 ≤ k ≤ m the length of Collatz sequence for each k is computed and the largest of these numbers is returned.
• Second returned value is the integer k, 1 ≤ k ≤ m, whose Collatz sequence has the largest length. In case there are several such numbers return the first one (the smallest).

For example maxLength(10) returns numbers 20 and 9

Which means that among the numbers 1, 2, 3,…, 10, nine has the longest Collatz sequence and its length is equal to 20.

In your program you may define other auxiliary functions with arbitrary names how ever the solution function of this task should be named maxLength(m).

In this task you are required to write a Python function max Value that returns two integers:

• First returned value: for each integer k, 1 ≤ k ≤ m the maximal integer in the Collatz sequence for k is computed and the largest of these numbers is returned.
• Second returned value is the integer k, 1 ≤ k ≤ m, whose Collatz sequence has the largest maximal member. In case there are several such numbers, return the first one the smallest).

For example max Value(10)returns the numbers 52 and 7

Which means that among the numbers 1, 2, 3,…, 10, seven has the largest maximal number in its Collatz sequence and that number is equal to 52.

In your program you may define other auxiliary functions with arbitrary names how ever the solution function of this task should be named maxValue(m).

In this task you are required to write a function main() where you test your functions The output should be similar to the following:

Allocated Marks :– See Course Description
Due Date :– See Course Description
Please refer to the Course Description for information relating to late assignments and special consideration.

### ORDER This ITECH1400 Fundamentals of Programming Assignment NOW And Get Instant Discount

Contact us on WhatsApp 