0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

約数関数:約数の数をカウントしグラフで観察

Posted at

プログラム

Processing
PrintWriter output;

void setup() {
  output = createWriter("divisorNum.csv"); 
  output.println("n,divisorNum");
  for (int n=1; n<=100000; n++) {
    int count = countDivisors(n);
    output.println(n+","+count);
  }
  output.flush();
  output.close();
  exit();
}

int countDivisors(int number) {
  int count = 0;
  for (int i = 1; i <= number; i++) {
    if (number % i == 0) {
      count++;
    }
  }
  return count;
}

828 KBのファイルが出力されます。
計算時間は数秒

エクセルで散布図

image.png

特徴① 層になる
特徴② 個数が存在しない層がある
特徴③ 83160と98280の約数の個数は128個

出現回数のグラフ

横方向にぎゅっと詰めて、回数をカウント

関連サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?