{"id":155134,"student_id":10,"content":"//迴圈版\nfunction gcd (a, b) {\n while (a != b) {\n if (a \u003e b) {\n a = a - b;\n } else {\n b = b - a; \n }\n }\n return a;\n}\n\n//遞迴版\nfunction gcd (a, b) {\n if (a == b) {\n return a;\n }\n if (a \u003e b) {\n return gcd(a - b, b);\n } else {\n return gcd(a, b - a);\n }\n}\n\n//測試\nfunction test (a, b, answer) {\n var result = gcd(a, b);\n console.log(`\n 程式算出 ${a} 和 ${b} 的最大公因數是 ${result}\n 正確答案是 ${answer} ,你${answer == result ? '答對了😃':'答錯了😡'}\n `);\n \n}\n\ntest(51, 85, 17); \ntest(60, 50, 10);\ntest(64, 48, 16);\ntest(99, 77, 11);\ntest(97, 17, 1);\n","created_at":"2020-06-03T18:16:50.486+08:00","updated_at":"2020-06-03T18:17:03.171+08:00","name":"輾轉相除法(完整版)","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":401,"hashid":"36ysgpgr","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Download Android APP (APK)
Screenshot
繁中
简中
English
日本語
1:1:1
1:1
Full Width
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer