Number of quality

xiaoxiao2021-03-06  48

I have seen this article, organize. Beginning program design. Note no one. Huh, huh

thought:

This knowledge of "greater than 2 is odd" will be reduced by half the space to be sieved. This knowledge is used to remove the "greater than 3". "Remove the" bigger number of 3 times) "greater than 5", it cannot be fed more than 5 (5). The number of times) uses "larger numbers of greater than 7" to be 7 "," removed more than 7 large (7 times) ... Using "larger than n", it cannot be divided by N ", Removed to N (N of N)

VB.NET version

DIM N, I, J

N = cint (me.txtmaxnbr.text)

DIM Z (N)

Dim StartTime as datetime = now

'INITIALIZE ARRAY

For i = 0 to n

Z (i) = 0

NEXT

'Mark Multiples of i

For i = 2 to n / 2 for j = 2 * i to n Step i z (j) = 1 Next Next

'Count unmarked Numbers, Which Are Primes Dim NBR = 0

For i = 2 to n if z (i) = 0 THEN NBR = 1 end if Next

Me.lblnbrprimes.text = NBRC # version INT k = int32.parse (textBox1.text); int b = 0; int [] a = new int [k 1]; for (int C = 0; c

For (int i = 2; i <= k / 2; i ) {for (int J = 2 * i; j <= k; j = i) {a [j] = 1;}}

For (int m = 2; m ) {IF (a [m]! = 1) b ;}

Label1.text = b.toString ();

转载请注明原文地址:https://www.9cbs.com/read-80875.html

New Post(0)