Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Factor Finder v1.0 (Numbers)
#1
I know there's lots of the younger audience on this forum, so I was fooling around in VB and came up with a function to find factors of numbers, and decided to make it into a program where you can input any number you want, and find the factors of that number. Thought it might be helpful for math courses that any of you might be taking.

Features:
• Lists all factors without duplicates in the listbox
• Displays number of factors of the specified number as a string in a label
• Finds factors for any number up to 8 digits (Example: 99999999)
• Find Factors button, or enter key is enabled to perform the task of the Find Factors button
• letters are disabled and any other symbols in the textbox
• No decimals
• Displays whether or not the number is a Prime number
• Displays whether or not the number is a Special number (0 or 1 only)

Note: 1 only has 1 factor; 1. Therefore it isn't a prime number because a prime number is defined as a number whose factor is 1 and itself. 1 is the factor of its own number, and so we call it a Special number. For 0 it is a special number because 0 means nothing, and therefore doesn't have any factors, because otherwise it would have infinity factors... (0x1, 0x2, 0x3... 0x1000, etc...). 0 is also defined as a Special number for that reason.

There is also a Clear All function that will reset everything back to the defaults, displaying no entered numbers and no factors. It also has a fairly clean looking GUI.

Preview Image:
[Image: previewtv.png]

File Information:
MD5 hash - 157FCFCDFB11E8805A208A9117C9E573

Download Link:
Factor Finder v1.0
Reply
#2
Hey thanks Infinity, this is actually helpful for my math. I am in Algebra 1 and we use factors ALL the time. Thanks again! PROPS!

Sidenote: Is there a source code please?
[Image: t5BWm.png]
Reply
#3
Seems very cool. Great share, thanks!
[Image: rara.png]
Reply
#4
(04-23-2011, 12:27 PM)The High Roller Wrote: Hey thanks Infinity, this is actually helpful for my math. I am in Algebra 1 and we use factors ALL the time. Thanks again! PROPS!

Sidenote: Is there a source code please?

I'll give you the basic function I used and other things like how I got the enter key to perform the task of button 1 which handled that function to a string.

Here's the rule I used to create the method for finding factors. If the input in the textbox was 1 I just manually created the output for the factors in the listbox and didn't use this code at all. (Using an if statement and Exit Sub command before this code).
Code:
'"1" will always be a factor so we'll always add it (with the exception of 0)
        ListBox1.Items.Add("1")
        'Defining how we find the factors of the number in Textbox1
        Dim N, x As Integer
        N = Val(TextBox1.Text)
        For x = 2 To N - 1
            If N Mod x = 0 Then
                ListBox1.Items.Add(x)
            End If
        Next
        'This is where we add the value of N (All the factors) to the listbox
        ListBox1.Items.Add(N)
        'Show the number input from Textbox1 into Label2 to confirm which number we are searching for factors (Just something fancy)
        Label2.Text = TextBox1.Text
        'Show in another label how many factors there are (how many listbox items there are)
        Label11.Text = ListBox1.Items.Count

        'Otherwise if listbox has 2 factor values, it has to be 1 and another number (itself) meaning it's a prime number
        If ListBox1.Items.Count = 2 Then
            'So display the value of Label12.Text to show that it's a prime number with this message
            Label12.ForeColor = Color.DarkOrange
            Label12.Text = "(This is a prime number!)"
        Else 'Otherwise, it's not a prime number, so don't show anything
            Label12.Text = ""
        End If

Here's for pressing Enter which will perform the task of button 1 click.
Code:
'Keypresses for in Textbox1
    Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        'If the key pressed is Enter
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            'Then perform the code for the Find Factors button
            Find_Factors.PerformClick()
        End If

Here is the code I used to only allow numbers into the textbox for the input
Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        'Only allow numeric entries for the textbox
        If AllowedChars.IndexOf(e.KeyChar) = -1 Then
            e.Handled = True
        End If

    End Sub

And I defined AllowedChars with this at the top under the Public Class
Code:
Dim AllowedChars As String = "0123456789" & vbBack

I'm glad you find it useful though, that's one of the reasons I created this besides the fact that I was just fooling around in Visual Basic a while ago. I knew at least a couple people would find it useful for one of their math courses.
Reply
#5
Looks like a nifty little program. This brings me back to my TI-83 calculator programming days...
Reply
#6
it works really nice I think. I used to have issues with a few things, but now I think it's pretty bullet proof lol. You can type in 0020, 0011, 013, or 14 and they will all result as the same thing as the numbers 20, 11, 13, 14. No decimals are allowed because only the number 0-9 will be inputted into the textbox, you can't type symbols in there or letters. With an 8 digit capacity as well. I could have made it 9, but it takes around 5-10 seconds to load some of the 9 digit numbers so I kept it to 8. 10 digit numbers worked, but it took a lot longer to load the factors in the listbox too.
Reply
#7
Seems pretty nice! This deserved a bump!
[Image: just-cause-2-header.jpg]
Reply
#8
Thanks, i'm happy that someone likes it. Hopefully others out there will find it useful, even though this was just a test project for me. I made sure that it does everything that it could do to my knowledge for finding factors.
Reply
#9
Good work. Nice to see I'm not the only one interested in factor finding... Just a few things though:

1. Your using Integers so your already restricted to the number of digits you can use. Use System.Numerics.BigInteger instead.
2. You test every number between 2 and the number entered. When you think about it though, no number bigger than 50 will divide evenly into 100. But more importantly, no two numbers larger than the square root of any number can multiply together to give a number smaller than the number. In your example you should use the Math.Sqrt function. Unfortunately, BigInteger doesn't provide that.
3. When displaying the results, I'd display as equations so that you get
1 * 100
2 * 50
4 * 25
5 * 20
10 * 10

instead of just
1
2
4
5
10
20
25
50
4. If you only want numeric entries, why not use a numeric up down instead of a text box? With numeric up downs you can only enter numbers and even use the up down arrows as well. Except, if your using BigInteger, you'd have to make your own numeric up down as the standard one only returns decimal numbers and, consequently, has a maximum limit.
5. If you start using BigInteger, you'll want a way to cancel factor finding so you'll need to use another thread that listens for the cancel.
6. Finally, if you really want a good, fast factor finder, use a faster language like C++

Here's my attempt at a factor finder:
http://www.mediafire.com/?4c2tllg6lkvllbd

Also, here's a link to a website with factor finding stuff. It even has this cool game on it.
http://factorfinder.tk/
Reply
#10
this will be nice if people can but on there phone for school and cheat on test lol


Aim = Pr8Source
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [TUT] MD5 Encrypter & Finder [VB.NET] Fragma 12 7,869 11-25-2012, 10:36 PM
Last Post: ƃu∀ ıʞƃu∀
  Help with VB 2010 (Numbers) Dεlluzion 1 854 06-22-2011, 12:07 PM
Last Post: Coding Support
  [VB.NET/Source] Converte Numbers To Letters : 1000 To One Thousand! ThePrinCe 7 1,879 06-18-2011, 04:09 PM
Last Post: Coding Support
  Compare Version Numbers cipherwar 3 1,439 05-10-2011, 12:02 PM
Last Post: Modestep
  Generate Random Numbers & Letters [ Small Function ] MYPE 22 4,191 04-02-2011, 05:25 PM
Last Post: Pyratepig

Forum Jump:


Users browsing this thread: 5 Guest(s)