package comp1110.exam;
* COMP1110 Final Exam, Question 1.1
public class Q1Tao {
Copyright By PowCoder代写 加微信 powcoder
* Print the Collatz sequence for the value n.
* If the input value is less than one, do nothing.
* Otherwise, print the input value n on a line by itself, and then:
* – if the input value is even, call tao again, passing in (n/2);
* – if the input value is odd and greater than one, call tao again, passing in (n*3+1);
* – if the input value is one, do nothing.
* Special rule (*not* part of the Collatz sequence):
* If the input value is 13120, print the string “Tao!” on a line by
* itself and then exit (without printing anything further).
* @param n the starting term of the Collatz sequence to print
* @see https://en.wikipedia.org/wiki/Collatz_conjecture
static void tao(int n) {
// FIXME complete this method
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com