Skip to content

Instantly share code, notes, and snippets.

@WeiChiaChang
Created January 16, 2023 01:48
Show Gist options
  • Save WeiChiaChang/37b4ee9852581d42a134c7e1c3a9913b to your computer and use it in GitHub Desktop.
Save WeiChiaChang/37b4ee9852581d42a134c7e1c3a9913b to your computer and use it in GitHub Desktop.
let a = 1
let b = 1
let count = 0
while (a <= 20) {
while (b <= 20) {
if (((a * 2 + b) <= 20) && a * 2 > b && a !== b) {
console.log(`發現等邊三角形 | 三邊長分別為: ${a}、${a}、${b}`)
count++
}
b++
}
a++
b = 1
}
console.log(`共找到 ${count} 組等腰三角形`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment