Created
January 16, 2023 01:48
-
-
Save WeiChiaChang/37b4ee9852581d42a134c7e1c3a9913b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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