Simple equation
Is there any simple equation to express each number as a product of its prime for example take number 140 http://youtu.be/WiQUuN7EXYM i am looking for a simple method to solve it with out going through lengthy procedure
Is there any simple equation to express each number as a product of its prime for example take number 140 http://youtu.be/WiQUuN7EXYM i am looking for a simple method to solve it with out going through lengthy procedure
thanks LP you too
thwho, everybody (!) can have access to these things if they just would be interested. Have a nice weekend.
QL's beaitful minds are LP and PG
This is easier but it takes longer:
Select a prime factor that your original number is divisible by and divide the original number by that prime factor. For example, if your original number equals 30, 2 is a prime factor so you would divide 30 by 2 to get 15.
Select a prime factor that the resulting number is divisible by and divide the new number by that prime factor. For this example, the new number equals 15. Because 3 is a prime factor, divide 15 by 3 to get 5.
Repeat Step 2 until you are left with a prime number. In this example, since 5 is a prime number, you would stop.
Write out the numbers you divided by and your last prime number to find the prime factorization. In this example, since you divided by 2, then 3 and were left with 5, your prime factors would be 2, 3 and 5.
You can use this VB macro in MS Excel:
Sub GetFactors()
Dim Count As Integer
Dim NumToFactor As Single 'Integer limits to < 32768
Dim Factor As Single
Dim y As Single
Dim IntCheck As Single
Count = 0
Do
NumToFactor = _
Application.InputBox(Prompt:="Type integer", Type:=1)
'Force entry of integers greater than 0.
IntCheck = NumToFactor - Int(NumToFactor)
If NumToFactor = 0 Then
Exit Sub
'Cancel is 0 -- allow Cancel.
ElseIf NumToFactor < 1 Then
MsgBox "Please enter an integer greater than zero."
ElseIf IntCheck > 0 Then
MsgBox "Please enter an integer -- no decimals."
End If
'Loop until entry of integer greater than 0.
Loop While NumToFactor 0
For y = 1 To NumToFactor
'Put message in status bar indicating the integer being checked.
Application.StatusBar = "Checking " & y
Factor = NumToFactor Mod y
'Determine if the result of division with Mod is without _
remainder and thus a "factor".
If Factor = 0 Then
'Enter the factor into a column starting with the active cell.
ActiveCell.Offset(Count, 0).Value = y
'Increase the amount to offset for next value.
Count = Count + 1
End If
Next
'Restore Status Bar.
Application.StatusBar = "Ready"
End Sub
Sub GetPrime()
Dim Count As Integer
Dim BegNum As Single 'Integer limits to < 32768
Dim EndNum As Single
Dim Prime As Single
Dim flag As Integer
Dim IntCheck As Single
Count = 0
Do
BegNum = _
Application.InputBox(Prompt:="Type beginning number.", Type:=1)
'Force entry of integers greater than 0.
IntCheck = BegNum - Int(BegNum)
If BegNum = 0 Then
Exit Sub
'Cancel is 0 -- allow Cancel.
ElseIf BegNum < 1 Then
MsgBox "Please enter an integer greater than zero."
ElseIf IntCheck > 0 Then
MsgBox "Please enter an integer -- no decimals."
End If
'Loop until entry of integer greater than 0.
Loop While BegNum 0
Do
EndNum = _
Application.InputBox(Prompt:="Type ending number.", Type:=1)
'Force entry of integers greater than 0.
IntCheck = EndNum - Int(EndNum)
If EndNum = 0 Then
Exit Sub
'Cancel is 0 -- allow Cancel.
ElseIf EndNum < BegNum Then
MsgBox "Please enter an integer larger than " & BegNum
ElseIf EndNum < 1 Then
MsgBox "Please enter an integer greater than zero."
ElseIf IntCheck > 0 Then
MsgBox "Please enter an integer -- no decimals."
End If
'Loop until entry of integer greater than 0.
Loop While EndNum < BegNum Or EndNum 0
For y = BegNum To EndNum
flag = 0
z = 1
Do Until flag = 1 Or z = y + 1
'Put message into Status Bar indicating the integer and _
divisor in each loop.
Application.StatusBar = y & " / " & z
Prime = y Mod z
If Prime = 0 And z y And z 1 Then
flag = 1
End If
z = z + 1
Loop
If flag = 0 Then
'Enter the factor into a column starting with the active cell.
ActiveCell.Offset(Count, 0).Value = y
'Increase the amount to offset for next value.
Count = Count + 1
End If
Next y
'Restore Status Bar.
Application.StatusBar = "Ready"
End Sub
or a simple equation :
First have a list of all Prime numbers : 2, 3, 5, 7, 11, 13, etc..
If number is 140 for example: then you only need to have all prime numbers before 70. (2,3,5,7,11,13, etc until 67)
Now: start from the end of this list and Divide 140 by the first one in this list and when you are able to divide it and get a 0 for remainder, then stop and you will have your first product.
140/7 = 20
so 140 = 7 x "20".
Now take 20 and do same thing you did for 140.
(find all prime numbers till half of 20) = (2,3,5,7)
20/7 = has non zero remainder, so
20/5 = has zero remainder then
20 = 5 x "4"
140 = 7 x 5 x "4"
Now do same for "4" and you will get 4 = 2 x 2
and the "2" will be 2 X 1
----------------------------------------
So your end will be 140 = 7 x 5 x 2 x 2
PeterGriffin, Is that the simple equation?
Input is X
If X is prime number Then
IF dynamic_new_Array[0] Null then
For (P=counter, Counter>=1, counter--)
Return dynamic_new_Array[counter]
Sorry, I cannot open the link. What is your question? 140 is not a prime number.
is there a link...i cannot even see it...:)
Because it;s a question that was given as homework in a school in Qatar..
(has to be answered and handed in by Sunday)
How is this question related with anything to Qatar?
lol :P
but im afraid we must call an ambulance first just in case
i think LP can answer this
me too
hi thewho i already lost conscious after reading the question :(
Ask baburao, he knows the answer