Determining If An Integer Entered Is Prime

Mar 22, 2009

i need to alter the code to determine if an integer entered by a user is prime preferably to determine if the number entered (between 1 and 50 is even or odd and prime from 51 to 100) i have the code for listing primes from 51-100 (or whatever range needed)but can i condense the code to a smaller foot print rather than have three different sections for each request

[Code]...

View 3 Replies


ADVERTISEMENT

Determining Prime Number In A Program?

Mar 14, 2012

I just started to use visual basic last month and I only know the basic codes. No matter how hard I try to understand the codes given by the other member, I can't understand it.So the program I'm making is to show all the inputted values and determine the even numbers, the odd numbers and the prime numbers.I don't know how to get the prime numbers.

Private Sub op1_Click()
a = InputBox("Input Endpoint: ")
For x = 1 To a

[code]....

View 1 Replies

Compute Whether An Integer Number Is Prime Or Not ?

Feb 28, 2008

What i'm trying to do is compute whether an integer number is prime or not. The program performs this analysis for all odd numbers from 3 up to an input integer limit, for example 100. If the integer in the range 3 to limit is prime, a message stating so is printed. Otherwise, a message is printed that lists at least one other integer divisor. The output for each analyzed number consumes one line of text.

A sample output is shown below:

Limit is 100:
Number 3: is prime
Number 5: is prime
Number 7: is prime

[CODE]...

I understand I need to use loops, boolean functions, vbmath(), strings and multi-line out via concatenation. So I can put this is words how I think it should be done but not so great putting the code together

Test all integers up to the SQRT of the number (100)

limit = math.sqrt(100) + 1

Followed by 1 For statement
For c = 0 to 100 step 2?
And an If statement
If ......
result = false

View 4 Replies

Forms :: Validate Each Textbox So The Number Entered Is An Integer?

May 11, 2009

I have designed a form with textboxes for numerical entry. I need to validate each textbox so the number entered is an integer, and is between 0-1000. I am struggling to find how to validate the data entry.

View 4 Replies

VB 2008 TryParse Method - When Enter A Character The Result Is As Though I've Entered An Integer

Mar 10, 2009

The code performs correctly when the input is an integer, but when I enter a character, the result is as though I've entered an integer. Can you tell me what's wrong with my TryParse statement?

Private Sub btnCompare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompare.Click

' Declare Local Variables

[CODE]...

View 2 Replies

Implement A Search For The Calendar So A Date Can Be Entered Into A Text Box Which Intern Moves The Calender To Show The Date Entered?

Oct 4, 2011

I am creating a Calender application using the monthly calender control.I am trying to implement a search for the calendar so a date can be entered into a text box which intern moves the calender to show the date entered. I have been try to figure this out with no luck, is it even possible to do?

View 2 Replies

VB - Relatively Prime Numbers ?

Mar 1, 2012

I have this number x and i wanted to find all numbers which are relatively prime to it.

My code so far:

For i = 1 To x-1
if [number n is relatively prime to x] Then
ListBox1.Items.Add(x)
End If
Next

View 2 Replies

How To Generate Prime Numbers

Oct 11, 2009

I want to rite an application that will print first n prime numbers. For example if user enters 7 you should display: 2 3 5 7 11 13 17 Assume that the user will enter only integer values from 1 to 100.

this is what I have so far

Dim intNum As Integer
Dim intX As Integer
Dim strOut As String

[Code]....

View 2 Replies

VB Prime Number Looping

Jan 18, 2010

I've been running through the online "Code Rules" tasks to work through Visual Basic. However I seem to be having a problem with one. The objective is to set a Button Click method to check if any number between 2-5000 is prime or not and to display it in the TextBox if it is prime. Here is what I have so far but it doesn't seem to work.[code...]

View 11 Replies

VB Prime Number Looping?

Mar 2, 2010

I've been running through the online "Code Rules" tasks to work through Visual Basic. However I seem to be having a problem with one. The objective is to set a Button Click method to check if any number between 2-5000 is prime or not and to display it in the TextBox if it is prime. Here is what I have so far but it doesn't seem to work

View 3 Replies

398 Million Prime Numbers And Growing?

Aug 17, 2011

[URL]

Each set of ( 1 million ) prime numbers is in a ZIP file just click on say 1st Million

on the left to download a list as a ZIP file.

Here is a similar page which is a lot easier on the eyes:>>

[URL]

These are of course great to use in any security application or as part of any password.

However with the list so readily available on the internet is it such a good idea to use a prime number as part of a password? Food for thought perhaps? ....

I guess it depends on how long it is too. :-)

You could try to remember one that is close to an important date or other number that you know maybe?

If you are more paranoid use more than one prime number in a password with other characters ( UPPER and lower case letters etc ).

[URL]

View 1 Replies

Check Whether An Inputted Number Is Prime?

Sep 9, 2009

I'm working on a console application in VB .net that checks a number that the user has inputted, and tells you whether the number is prime.

The number that has to be inputted has to be between 1 and 100. I have all the code so far and at the moment it can check whether the number is or isn't within the boundries.

View 4 Replies

Displaying All Prime Numbers In ListBox

Mar 13, 2010

I am suppose to write a program using if statements and loops: Create an application that reads an integer number from the user and then displays in the List Box all prime numbers (for this project we are going to violate "positive" rule and make our prime numbers be negative as well) between user's number and zero 5 numbers in one row. The application also displays how many prime numbers there are between user's number and zero, and the total sum of all these prime numbers.

View 1 Replies

Loop Displaying Prime Numbers?

Jun 20, 2012

I'm having a serious brain fart over this but I need a looping statement that will display all prime number from 6 to 10000.

View 3 Replies

Prime Numbers In Console Application?

Mar 4, 2010

i need a prime numbers in console application in vb.net

View 1 Replies

Prime Numbers With Inline Functions?

Jul 9, 2009

Just out of curosity, what's wrong with the following line. I'm trying to create a range of integers (3,4,5...,50) and then filtering out only those numbers which are not divisible by any integer less than themselves (bruteforce way of finding primes).

Enumerable.Range(3, 50).Where(Function(x) Not Enumerable.Range(2, x - 1).Any(Function(y) x Mod y = 0))

View 1 Replies

Program For Prime Numbers Stumped?

Feb 25, 2010

Simple Program for Prime numbers stumped?

View 1 Replies

Vb Function For Making Prime Numbers?

Nov 21, 2010

I made a form with a two text boxes for user input.A (lower bound) and an (upper bound), and then a text box to display all prime numbers in that range.I can't figure out what I am doing wrong, my error checking works properly but my math onlyreturns a true or false.

Function
Prime(ByVal findPrime
As Int32)

[code].....

View 1 Replies

Basic Prime Numbers Array Program?

Apr 20, 2011

First off, I'm not sure if this is the right forum, please move it if it isn't. I am only just beginning with visual basic and I am trying to write a basic program to calculate the prime numbers from 1 to 100. This is what I have so far:

[Code]...

View 3 Replies

Create A Function That Checks If A Number Is A Prime?

May 10, 2011

I've been trying to create a function that checks if a number is a prime. according to [URL]..I have created a function although It doesn't work as expected.

[Code]...

It sometimes returns true for composite numbers. oh and I know if you google it you get functions that do this, but most of them look inefficient so i'm trying to make my own.

View 4 Replies

Create A Program That Finds Prime Numbers?

Oct 7, 2010

So I have been assigned to create a program that finds prime numbers. And then for the final part of the program I need to have the computer find the millionth prime.

View 3 Replies

Determine Prime Numbers - Calculate Button?

Mar 17, 2011

I am creating an application that takes two numbers (lower and upper) and determines the prime numbers

Public Class primeNumber
Private Sub calculatePrimesButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculatePrimesButton.Click
'declare variables
Dim number As Long
[Code] .....

Once I hit the calculate button nothing comes up. I've tried adding the first code inside the function with the remaining code but no result. Now I'm putting the first code in with the calculate prime button. I am guessing there's a sqrt method that needs to be applied but I am not sure if it should be part of the function or the main?

View 14 Replies

Function To Check For Prime Numbers Within A Range?

Dec 4, 2010

I have two user inputs (as textboxes) for two numbers I'm looking to check for all the prime numbers with the range of those two numbers and display them within a multiline textbox, however my code returns nothing but zeros, and I have seen easier ways to do it without functions but I am curious as to how to go about calculating primes within the function.[code]...

View 7 Replies

Get The Prime Number From The User And Give Its Factors?

May 25, 2010

i wrote some code that is suppose to get the prime number from the user and give its factors but there's some error

Dim t As Double
Dim n As Double
Dim ans As Double
Dim exp1 As Double

[code].....

View 2 Replies

Make A Program For Finding Prime Numbers?

Dec 21, 2011

I needed to make a program for finding prime numbers. The logic is that you have to put limits n & m and then LOOP and odd-integer P between n & m inclusive. I have a button to click on my form that displays 2 message boxes, one saying " enter upper limit" and the other say "enter lower limit". I need now to get the results of the odd prime numbers between the limits into a list box!

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code].....

View 39 Replies

Prime Factor Finding - Adding CheckBox?

Nov 13, 2009

So far I have made a program that can find all the factors of a number (e.g type in 24 and you'll get 1 * 24, 2*12, 3*8, 4*6,). What I would like to do now is add a check box (called Show_Prime_Factors_chk) that when checked it will also show all the prime factors below all the normal factors.

View 2 Replies

Prime Number Checker Unbelievably Slow?

Feb 13, 2011

I have this piece of code which checks whether a given number is prime:

If x Mod 2 = 0 Then
Return False
End If

[code].....

View 8 Replies

Prime Number Output With List In Textbox

Dec 11, 2009

I am not getting an output with a list, I can only get the last number of the statement in a text box.

Dim lowerLimit, upperLimit, primeNumber As Integer
Dim isPrime As Boolean = False
lowerLimit = CType(TextBox1.Text, Integer)
upperLimit = CType(TextBox2.Text, Integer)
While lowerLimit < upperLimit
[Code] .....

View 6 Replies

Calling A Function To Display A Range Of Prime Numbers

Dec 5, 2010

I am trying to create a form that allows users to input two numbers a high bound and a low bound then when you click the calculate button it determines all the primes within the range and displays those numbers within a multi-line text box. It seems I have everything working except how to display the prime numbers, the result from the following code displays nothing but zeros so I suspect that the range is not being saved somehow? I have asked this on other sites and people just give me completely different code or their own, can anyone help me with this specific code without changing the underlying code, I have a feeling I might be missing a variable or I am calling the function incorrectly.[code]

View 2 Replies

Made A Program For Generating Prime Numbers In A List Box?

Dec 24, 2011

So I made a program for generating prime numbers in a list box. My initial code had them listed like this:

2
3
5
7
..ect

Now I have them listed in pairs like this :

[Code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved