KarloZP

M. Iqbal Suhardimas ( 2018 804 302 ) | Soal No. 2 | Page 4 | UTS

Oct 28th, 2020 (edited)
1,737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. clear
  2. bilanganpertama=0
  3. bilangankedua=1
  4. total=0
  5.  
  6. echo "M. Iqbal Suhardimas ( 2018 804 302 ) | Soal No. 2 | Page 4 | UTS ";
  7. echo;
  8. read -p "Masukan batas deret Fibbonaci? " angka;
  9.  
  10. for (( i=0; i<$angka; i++ ))
  11. do
  12.  
  13.     hasil=$((bilanganpertama + bilangankedua))
  14.     if [[ "$i" -ge "$angka-1" ]]
  15.     then
  16.         operator="="
  17.         total=$hasil
  18.         echo -n "$bilanganpertama$operator$total";
  19.     else
  20.         operator="+"
  21.         echo -n "$bilanganpertama$operator";
  22.         bilanganpertama=$bilangankedua
  23.         bilangankedua=$hasil
  24.        
  25.     fi
  26. done
  27. echo;
  28. echo "Jumlah Deret adalah $total";
  29. echo;
  30. echo "UTS No.2 : https://pastebin.com/7Ty9VXeH";
  31. echo "UTS No.3 : https://pastebin.com/tvuXgZA8";
  32. echo "Tugas Harian No.4 : https://pastebin.com/q55XucAA";
  33. echo "Tugas Harian No.5 : https://pastebin.com/DQTrSek8";
  34.  
Add Comment
Please, Sign In to add comment