Skip to content

習題 2 -- JavaScript 練習 #4

@ccckmit

Description

@ccckmit
  1. 請寫一個程式可以印出指定數量的 * 號

例如: star(5) 會印出 5 個 * 號

star(5)

*
*
*
*
*
  1. 請寫一個函數可以印出 a..b 之間的所有整數

例如: between(3,8) 會印出

3
4
5
6
7
8

加分題

3 請寫一個函數 primeBetween(a,b) 可以印出 a..b 之間的質數

例如 primeBetween(3,15)

3
5
7
11
13

記得善用函數,先寫一個判斷是否為質數的函數 isPrime(n) 去判斷會比較好

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions