Answered # Prime Factorization

cghtkh 9 eceisl pyTony 888 Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

Here is some code to help you, but you need to do some work.

```
# define your own function that check for prime
def isPrime(x):
pass
def primeFactorization(num):
pfactors = []
while True:
j = 2
while j < num+1:
if num%j==0 and isPrime(j):
num = num/j
pfactors.append(j)
break
j+=1
if num==1:
break
return pfactors
```

0

Title says all. I need to make a code that gives the prime factorization of a number and put them in a (this is important) a list.

def is_prime(num):

divisor=2

if(num==1):

return False

while(divisor<=num/2):

if(num%divisor==0):

return False

else:

divisor=divisor+1

return True

def print_prime_factors(num):

for i in range(2,num+1):

if(num==1):

break

while(num%i==0):

print (i)

num=num/i

i=next_prime(i)

I do not think that your code is working properly. Here is my code. You should call the last function.

0

You do not need to test all numbers neither test for prime as factorin wjile loop ensures prime. You can test for only valid prime candidates n * 6 +- 1 after testing with 2 and 3. BTW this is old solved thread and I do not know how much this post helps OP, make own thred with link to old one you read. !lso the function next_prime in your code does not exist.

This question has already been answered. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...