Please check following link for primality test. http://en.wikipedia.org/wiki/Primality_test
Following code is not in the optimized form...and it may contains some error please check it carefully before using ... int[] numbers = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; System.Collections.ArrayList PrimeNumbers = new System.Collections.ArrayList(); Boolean isPrime = false; for (int loop = 0; loop < numbers.Length; loop++) { int intNumberToTest = numbers[loop]; for (int intTest = 2; intTest <= Convert.ToInt32(Math.Sqrt(intNumberToTest)); intTest++) { if (intNumberToTest % intTest == 0) { isPrime = false; break; } else isPrime = true; } if(isPrime) PrimeNumbers.Add(intNumberToTest); }
Use text-editor notepad++
12=5+7
To write a composite whole number as the product of its prime factors is to write its prime factorization.
One way to do this is to write a function that checks if a number is prime: def isPrime(number): for i in range(2, number): if number%i == 0: return False return True Then create variables to track how many primes have been found and a variable to track which number is being tested for being prime. Increment that variable and test it, and if it is prime print it out (or save it somewhere) and increment the variable being used to track how many primes have been found: targetPrimes = 10 #number of primes to find primesFound = 0 #number of primes found i = 1 while (primesFound < targetPrimes): i += 1 #first number tested is 2 if isPrime(i): print(i) primesFound += 1
It is 1*79 = 79.0 because 79 is a prime number
It is called the prime factorisation (or prime decomposition) of the composite number.
1450 as a product of primes = 2 * 5 * 5 * 29
5x5x3
1 + 17 = 18 5 + 13 = 18 7 + 11 = 18
72 = 2 x 2 x 2 x 3 x 3
770 is not prime; however, it can be written as a productof primes:770 = 2*5*7*11.
20 as a product of primes = 2 * 2 * 5