1. 1.
    +4
    public class form1
    sub checkprime(byval a as integer, byref p as boolean)
    dim k as integer
    p = true
    for k = 2 to a - 1
    if a mod k = 0 then p = false
    next
    if a = 0 or a = 1 then p = false
    end sub
    private sub button1_click(byval sender as system. object, byval e as system. eventargs) handles button1.click
    dim arr(), n, i, counter as integer
    dim prime as boolean
    randomize()
    n = inputbox("enter array size") - 1
    redim arr(n)
    for i = 0 to ubound(arr)
    arr(i) = i
    next i
    for i = 0 to ubound(arr)
    checkprime(arr(i), prime)
    if prime then
    textbox1.text = textbox1.text & arr(i) & vbtab
    counter += 1
    end if
    next i
    textbox1.text = textbox1.text & vbcrlf & "there are " & counter & " prime numbers" & vbtab
    end sub
    end class

    al panpa
    ···
   tümünü göster