![]() |
| ||
| How do you calculate prime numbers?? So I'm taking this introductory class on Visual Studio 2008 and I've been pretty lost since it started. Our current project is to write a code that will allow you to type in a starting and ending point then click the calculate button to calculate the factors of each number in the current range and display that in listbox1 then lablel1 needs to have a count of all the prime numbers that exist in that range and listbox 2 needs to show a list of all those prime numbers. My code currently calculates all of the factors in the range but I need help calculating the prime numbers and showing the count in label1 and the actual numbers in listbox2. If anyone has any suggestions they would be greatly appreciated. Here is my current code, i know its sloppy so if you have any suggestions to clean it up they would be appreciated as well. Private Sub CalculateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateToolStripMenuItem.Click Dim beginInteger, endInteger As Integer Dim primeInteger, prime1Integer, displayInteger As Integer Dim remainderInteger, primeNumberInteger As Integer Dim outputString As String beginInteger = CInt(fromTextBox.Text) endInteger = CInt(toTextBox.Text) ListBox1.Items.Add(" N Factors") primeInteger = 0 For primeInteger = beginInteger To endInteger displayInteger = primeInteger.ToString("D4") outputString = Format(prime1Integer, "0000") & " " For prime1Integer = 1 To primeInteger remainderInteger = primeInteger Mod prime1Integer If remainderInteger = 0 Then 'primeNumberInteger += 1 outputString &= " " & prime1Integer End If Next ListBox1.Items.Add(outputString) Next End Sub |
| ||
| Re: How do you calculate prime numbers?? Try this... 1. http://www.xtremecomp.com/tips/xttip19.htm 2. http://forums.invisionpower.com/lofi...p/t210744.html 3. http://social.msdn.microsoft.com/For...-a73ff6f4abaa/ I just google it for you seems you don't want to do it... ahehehehe |
| All times are GMT -4. The time now is 7:38 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC