mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
13 lines
238 B
Bash
13 lines
238 B
Bash
#!/usr/bin/env bash
|
|
|
|
# 查找 10 以内第一个能整除 2 和 3 的正整数
|
|
i=1
|
|
while [[ ${i} -lt 10 ]]; do
|
|
if [[ $((i % 3)) -eq 0 ]] && [[ $((i % 2)) -eq 0 ]]; then
|
|
echo ${i}
|
|
break;
|
|
fi
|
|
i=`expr ${i} + 1`
|
|
done
|
|
# Output: 6
|