Question

Using a user inputted number through a texbox that runs a code that lists the prime...

Using a user inputted number through a texbox that runs a code that lists the prime factor decomposition in VB.net

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per requirement submitted above kindly find below solution.

Here new windows forms application in VB.net is created using visual studio 2019 with name "VB_PrimeFactors". This application contains a form with name "Form1.vb".Below is the details of this form.

Form1.vb[Design] :

Form1.vb:

Public Class Form1 'VB class
'button to find prime factors
Private Sub btnPrimeFactors_Click(sender As Object, e As EventArgs) Handles btnPrimeFactors.Click
'taking number entered by user
Dim number As Integer = Integer.Parse(txtNumber.Text)

'using for loop
For index = 2 To number
'this for loop will goes from 2 to number
'checking whether number is divisible by index
If number Mod index = 0 Then
'if number Mod 2 is zero this means remainder is 0 then
Dim k As Integer = 2
'declaring variable to store prime number status
Dim primeStatus As Boolean = False
'using while loop
While k < index / 2
'checking if index mod k is zero , remainder is zero
If index Mod k = 0 Then
primeStatus = True 'set prime status
Exit While 'this line is used to exit while loop
End If
k = k + 1 'increment value of k
End While
'checking value of variable primeStatus
If primeStatus = False Then
'if number is prime then
lblHeader.Text += index & " "
End If
End If
Next
End Sub
End Class

==================================

Output :Run application using F5 and will get the screen as shown below

Screen 1:


NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Using a user inputted number through a texbox that runs a code that lists the prime...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the...

    Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the console (inclusive). The identified prime numbers must be stored in an array . The inputted number should be between 0 and 1000 (inclusive). array is large enough to o Make sure your hold all the prim e numbers. Dynamic memory allocation is not required for this assignment, so you can have unused space in your array Make sure you can handle the cases of...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • Your program  write a program to test whether a number is prime or not. Your program should...

    Your program  write a program to test whether a number is prime or not. Your program should ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers. The program should continue to ask for input, till it sees a 0, when it exits. Please submit printed pseudocodeshould ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers....

  • Write a program to draw this number triangl using MIPS assembly language The number of rows is inputted from keyboard....

    Write a program to draw this number triangl using MIPS assembly language The number of rows is inputted from keyboard. 6. Write a program to draw this number triangle 1 1〈--|--〉1 The number of rows is inputted from keyboard. 6. Write a program to draw this number triangle 1 1〈--|--〉1 The number of rows is inputted from keyboard.

  • 3.2 Write code to calculate 2 lists: listA: all prime numbers between 1 and 30. listB:...

    3.2 Write code to calculate 2 lists: listA: all prime numbers between 1 and 30. listB: first 10 numbers in the Fibonacci series. Convert these lists to sets: set and setB. Your script must then calculate and display the intersection and the difference between these sets. Answers: Intersection: Difference: 2 Write out the complete script. 3.3 Add code to the script in 3.2 to allow your code to save both sets and the results to a file called "setdata.txt" in...

  • JavaScript for a HTML webpage code a Fibonacci Sequence, have the user defining the number of...

    JavaScript for a HTML webpage code a Fibonacci Sequence, have the user defining the number of runs. (use a function and either While or For statement)

  • Write code to read in an even number from the user (using the console and Scanner...

    Write code to read in an even number from the user (using the console and Scanner class). Use a loop to continue to ask for user input until you get an even number. Use a Java-provided exception class to account for the user entering non-numeric data.

  • A prime number is a number that can be evenly divided by only itself and

    A prime number is a number that can be evenly divided by only itself and 1. For example, the number 5 is prime because it can be evenly divided by only 1 and 5. The number 6, however isn't prime because it can be evenly divided by 1,2,3, and 6. Write a bool function named isprime that takes an integer as an argument and returns true if the argument is a prime number or false otherwise. Use the function in...

  • Need help with code using pointer only in C Ask the user to enter a number...

    Need help with code using pointer only in C Ask the user to enter a number between 1 and 10 •Check if the user has complied. •Keep asking the user for a number between 1 and 10 until the user complies. •Then calculate N! (no recursion)

  • USING C# AND PSUDOCODE PLEASE : A palindromic prime number is a number that is both...

    USING C# AND PSUDOCODE PLEASE : A palindromic prime number is a number that is both prime number and a palindrome number. For example, 131, 313, and 757 are palindromic prime numbers. Design (pseudocode) and implement (source code) a program (name it PalindromicPrime) to display the first 50 palindromic prime numbers, 10 per line separated by one space. The program defines the following methods: Method isPalindome() to check if a number is palindrome or not. Method isPrime() to check if...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT