Examining Reality; Speaking the unspeakable - with the help of truth serum

Advertisements

Event Calendar

  • 09 February 2008: Chinese New Year slacking break!

Subscribe!

Get new post updates immediately when they come out

I can’t comment inside the comment box!

Ok, it’s really crazy for me to put this in a post, but just how do you post inside my tag board? Whenever I try to post something there, the whole thing just disappears, along with my post!

I’ll tear it down the moment I have time to spare, if I don’t tear out my hair first!

School has been quite a handful to me, though it isn’t as bad as JC times, the lessons were mostly easy to understand, since I have a pretty ok foundation in programming in general, so I ended up finishing all my practicals early, and having nothing to do for the rest of the lessons.

I tried typing wisecrack comments into my program codes (done!), turning on strict mode (done!), mentored my junior peers (done!) and pestered the teachers to show me some of their favourite tricks (done!).

Rather than bore myself to death, I decided to tax those brain cells by looking for ridiculous stuff to do with Visual Basic. Since I’m still at a pretty basic stage, I decided to try my hand at coding something to find prime numbers from 1 to 10000.

In case you had noticed, it is a nightmare for someone of my mathematics caliber to try to do this using mathematics. Rather, I put VB to the crunch, and set it off to do all the grunt work.

Public Class Prime_Numbers 

Private Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShow.Click  

'Specifies starting point for our prime        Dim iCounter As Long = 1 

'Specify the last number in range to check for prime 

        Do While iCounter <= 10000 

Dim loopCounter As Long = 1     'Used to find prime numbers 

            Dim testCounter As Integer 

            Do While loopCounter <= iCounter 

                'Looping through numbers from 1 till our current number to check for all factors 

                Dim modResult As Long 

                modResult = iCounter Mod loopCounter 

                'If a multiple is found, found counter is incremented 

                If modResult = 0 Then 

                    testCounter += 1 

                End If 

                'Setting stage for next divisor to be tested as a potential multiple 

                loopCounter += 1 

            Loop 

loopCounter = 1 'Resetting our loopcounter for the next number to be tested 

If testCounter = 2 Then 

                'Prime numbers can only be divided by 1 and itself 

                'Thus there can only be 2 factors 

                TextBox1.Text += iCounter & vbCrLf 

            End If 

'Resetting our test counter back to 0 for the next number to be tested 

            testCounter = 0 

'Stage set for the next number to be tested 

            iCounter += 1 

        Loop 

    End Sub 

End Class

Prime Number Program
The program in action

Anyway, the last prime number in the range from 1 to 10,000 is actually 9973. Is there anyone who is interested in purchasing this neat little tool for their next math quiz, or are you such a math god that you do not even need a puny applet from a programming noob to help you dominate your opponents?

3 Responses to “I can’t comment inside the comment box!”

Write a response | Back to article

  1. let’s see if this works! last time it didn’t!

  2. I didn’t really read this post because I was scanning through it when I came across the whole barrage of coding lingo which is like tamil to me but I just want to say Hi!

  3. Hi! |\/|r |\/|0r0|\|, P|-|34R t3|-| c0|)3
    (Hi! Mr Moron, Fear the code)

    Ok, I’m extreme…ly noob. Anyone still wants my program?
    *Waves it around and crying*

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>