算法。。。
1. 求100以内的所有质数
1 private void button3_Click(object sender, EventArgs e) 2 { 3 System.Text.StringBuilder sb = new StringBuilder(); 4 5 int m; 6 int j; 7 8 for (int i = 2; i < 100; i++) 9 { 10 m = (int)Math.Sqrt(i); 11 for (j = 2; j <= m; j++) 12 { 13 if (i % j == 0) 14 break; 15 } 16 if (j > m) 17 { 18 sb.Append(i.ToString() + ","); 19 } 20 } 21 22 MessageBox.Show(sb.ToString()); 23 }