Write Script to read a positive integer number then it computes the following sequence: If the number is even, halve it If it is odd multiply it by 3 and add1
You should repeat this process until the value is 1, printing out each value and how many of these operations you performed.
#! bin\csh
echo "please enter any integer number :) "
set count=0
set number=$<
while($number != 1)
if($number % 2) then
@ number = number * 3 + 1
else
@ number = number / 2
endif
echo " $number "
@ count = count ++
end
echo I performed these operations $count times
When I run the script I get the following error:
@: Expression Syntax.