05
May
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
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?
on May 5th, 2007 at 11:15 pm
let’s see if this works! last time it didn’t!
on May 6th, 2007 at 10:28 pm
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!
on May 6th, 2007 at 10:34 pm
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*