cs1520: lab 5 ============= 1.1 Assignment Submission ------------------------- Submit a fake assignment using the online submission interface, if you have not already done so. Select "assignment #0" from the dropdown box. 1.2 Hello PHP ------------ Setup your PHP workspace using the instructions on this page: http://db.cs.pitt.edu/courses/cs1520/spring2012/phpsetup.html Write a simple "Hello World" to make sure that everything is working. 2. The Collatz conjecture: -------------------------- Given a positive integer n, form a sequence by iteratively performing the following operations: If n is even, divide by 2. If n is odd, multiply by 3 and add 1. The sequence stops when n is equal to 1. It is believed (but not yet proven) that regardless of the starting number, all sequences end at 1. Write a php function that takes a starting number and returns the length of the collatz chain for that number. Then find the length of the longest sequence for starting numbers less than 100. 3. Reading a file ----------------- The file "numbers.csv" contains 21 lines, each having 10 numbers, separated by commas. Write a php script to read the numbers into an html table with 21 rows and 10 columns. If the number is larger than 13, color the cell blue. Here is some sample code to start: $filename = 'numbers.csv'; $input = fopen($filename, 'r') or exit("unable to open file $filename"); echo " "; # read line by line echo ""; while ($line = fgets($input)) { # split the line on commas: # loop over every item and output either # # or # } echo "
$item$item
"; fclose($input);