Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in VB Net i am trying to find the Prime factorization of a inputted number n ex) 4 = 2 x 2, 16 = 2

image text in transcribed

in VB Net i am trying to find the Prime factorization of a inputted number "n"

ex) 4 = 2 x 2, 16 = 2 x 2 x 2 x 2.

The code works for 4 = 2 x 2, but when i input 16 it gives me : 2 x 4 x 2 (4 is not prime, should be 2 x 2 )

32 gives me : (2 x 4 x 2 x 2 ).

How could i fix this ? Thank you for your help

Public class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.click Dim n As Long Dim i As Long Dim count As Long n = TextBox1.Text Do Until n = 1 For i = 2 To n If n Mod i = @ Then n = n / i TextBox2.Text += i & "" count += 1 TextBox3. Text = count End If Next i Loop End Sub

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

AIS systems are automated? True or False

Answered: 1 week ago