Xioth

Bash - TD1 - suite.sh

Jan 26th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.25 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 1 ]
  4. then
  5.     echo "Ce programme n'accepte qu'un et un seul argument"
  6.     exit 1
  7. else
  8.     u=$1
  9.  
  10.     while [ $u -ne 1 ]
  11.     do
  12.         if [ $((u%2)) -eq 0 ]
  13.         then
  14.             u=$((u/2))
  15.             echo $u
  16.         else
  17.             u=$((3*u+1))
  18.             echo $u
  19.         fi
  20.     done
  21. fi
Add Comment
Please, Sign In to add comment