Week3:hw3 判斷質數


Posted by rockyooooooo on 2021-04-19

這一題要先找出數字的所有因數,所以直接用上一周 hw4:印出因數的 code 來改寫
因為質數只會有兩個因數, 1 跟自己
唯一的例外數字 1,既不是合數也不是因數,按題目要求,視為合數處理

  1. 先把所有因數都存在一個 array
  2. array 的長度就是因數的個數









Related Posts

Day 159

Day 159

SQL入門語法

SQL入門語法

篩選方法- map( ), filter( ), find( ), some( )

篩選方法- map( ), filter( ), find( ), some( )


Comments