Calculating the Collatz Conjecture
Each time you call File.AppendAllText, you create a new files stream and close it afterwards. Therfore, you should not write the result into the file by calling File.AppendAllText n times. just use string.Join instead:

var content = string.Join(Environment.NewLine, list);
File.WriteAllText(content);




Your code seems not work correctly, because if z == 1 is reached (which is given as initial state), the inner while loop is not entered anymore. I suppose there is a z = num; missing at the end of the outer while loop.



And in the very unlikely event, that you find a start number where the collatz conjecture does not ends up with 1, your program remains in an endless loop and you will never find out which number it was ;).