E D R , A S I H C RSS

Full text search for "prime"

prime


Search BackLinks only
Display context of search results
Case-sensitive searching
  • SummationOfFourPrimes/곽세환 . . . . 74 matches
         #define PRIME_TABLE_SIZE 100
         int primeTable[PRIME_TABLE_SIZE];
         int primeCnt = 0;
         void makePrimeTable()
          primeTable[primeCnt++] = 2;
          for (i = 3; primeCnt < PRIME_TABLE_SIZE; i += 2)
          for (j = 0; j < primeCnt; j++)
          if (i % primeTable[j] == 0)
          else if (i / primeTable[j] <= primeTable[j])
          primeTable[primeCnt++] = i;
         bool isPrime(int n)
          int sumOfThreePrimes;
          int primes[4] = {0};
          makePrimeTable();
          primes[0] = primes[1] = primes[2] = primes[3] = 0;
          if (isPrime(i))
          primes[0] = i;
          sumOfThreePrimes = input - i;
          if (primes[0] == 0)
          if (sumOfThreePrimes == primeTable[i] + primeTable[j] + primeTable[k])
  • BabyStepsSafely . . . . 62 matches
         This article outlines the refactoring of an algorithm that generate the prime numbers up to a user specified maximum. This algorithm is called the Sieve of Eratosthenes. This article demonstrates that the granularity of the changes made to the source code are very small and rely completely on the ability to recompile and test the code after every change no matter how small. The step where the code is tested insures that each step is done safely. It is important to note that the execution of tests do not actually guarantee that the code is correct. The execution of the tests just guarantees that it isn't any worse that it used to db, prior to the change. This is good enough for the purposes of refactoring since we are tring to not damage anything thay may have worked before Therefore for each change in the code we will be recompilling the code and running the tests.
         The code that is to be refactored has existed in the system for awhile. It has undergone a couple of transformations. Initially it returned an array of int variables that are the prime numbers. When the new collection library was introduced in Java2 the interface was changed to return a List of Integer objects. Going forward the method that returns a List is the preferred method, so the method that returns an array has been marked as being deprecated for the last couple of releases. During this release the array member function will be removed. Listing1, "Class GeneratePrimes," contains the source code for both methods.
         The algorithm is quite simple. Given an array of integers starting at 2.Cross out all multiples of 2. Find the next uncrossed integer, and cross out all of its multiples. Repeat until you have passed the square root of the maximum value. This algorithm is implemented in the method generatePrimes() in Listing1. "Class GeneratePrimes,".
         pulbic class GeneratePrimes
          public static List primes(int maxValue)
          int [] primes = generatePrimes(maxValue);
          for(int i = 0; i <primes.length; ++i)
          result.add(new Integer(primes[i]));
          public static int [] generatePrimes(int maxValue)
          // get rid of known non-primes
          for[j]=false; // multiple is not prime
          // how many primes are there?
          int [] primes = new int[count];
          // move the primes into the result
          if(f[i]) // if prime
          primes[j++] = i;
          // return the primes
          return primes;
         The test cases for the GeneratePrimes class are implemented using the JUnit testing framework. The tests are contained in class called TestGeneratePrames. There are a 5 tests for each return type (array and List), which appear to be similiar. Our first step to insure보증하다, 책임지다 that we are starting from a stable base is to make sure what we have works.
         Therefore, recompile the both GeneratePrimes and TestGeneratePrime and run the tests.
  • SummationOfFourPrimes/1002 . . . . 41 matches
          isAllPrimeNumber:
         class PrimeNumberList:
          if self.isPrimeNumber(i):
          def isPrimeNumber(self,aNum):
         class PrimeNumberTest(unittest.TestCase):
          def testPrimeNumber(self):
          self.assertEquals([2,], PrimeNumberList(2).getList())
          self.assertEquals([2,3], PrimeNumberList(3).getList())
          self.assertEquals([2,3,5], PrimeNumberList(5).getList())
          self.assertEquals([2,3,5,7,11], PrimeNumberList(12).getList())
          self.assertEquals([2,3,5,7,11,13,17,19], PrimeNumberList(20).getList())
         class PrimeNumberList:
          if self.isPrimeNumber(i):
          def isPrimeNumber(self,aNum):
          primeNumberList = PrimeNumberList(n)
          for eachPrimeNumberSeq in selectionFour(primeNumberList.getList()):
          if sum(eachPrimeNumberSeq) == n:
          print eachPrimeNumberSeq
         C:\WINDOWS\system32\cmd.exe /c python SummationOfFourPrimes.py
          1 0.075 0.075 1.201 1.201 summationoffourprimes.py:13(createList)
  • SummationOfFourPrimes/김회영 . . . . 25 matches
         int* set_prime_array(int* prime_array,int number);
         bool check_prime_number(int n);
         void find_four_number(int* prime_array,int count,int number);
          prime_array = set_prime_array(prime_array,number);
          find_four_number(prime_array,count,number);
          delete[] prime_array;
         int* set_prime_array(int* prime_array,int number)
          int* prime_array = new int[number];
          if(check_prime_number(i)==true)
          prime_array[count]=i;
          return prime_array;
         bool check_prime_number(int n)//전달된 값이 소수인지를 판별합니다.
         void find_four_number(int* prime_array,int count,int number)
          if(prime_array[a]+prime_array[b]+prime_array[c]+prime_array[d]==number)
          cout<<prime_array[a]<<","<<prime_array[b]<<","<<prime_array[c]<<","<<prime_array[d];
         [SummationOfFourPrimes]
  • SummationOfFourPrimes/문보창 . . . . 23 matches
         // no10168 - SumOfFourPrimes(a)
         void setPrimeArr(int * prim);
         void showPrime(int prime1, int prime2, bool isEven);
          int primes[MAX] = {2, 3, 5, 7, 11, 13,};
          setPrimeArr(primes);
          findPrim(number - 5, false, primes);
          findPrim(number/2, true, primes);
          findPrim(number/2 - 1, false, primes);
          findPrim(number/2 + 1, false, primes);
          int prime1, prime2;
          prime1 = prim[i];
          prime2 = formerPrim - prime1;
          if(prime2 > prim[j] && prime2 % prim[j] == 0)
          showPrime(prime1, prime2, isEven);
         void showPrime(int prime1, int prime2, bool isEven)
          cout << prime1 << " " << prime2 << " ";
          cout << prime1 << " " << prime2;
         void setPrimeArr(int * prim)
          int countPrimes = 6;
          bool boolPrimes;
  • SmithNumbers/이도현 . . . . 17 matches
         void prime_factor(int, int*);
         int prime(int); /* 소수 : 200, 소수 아님 : 100 */
          int arr_separation[ArSize] = { 0 }, arr_prime[ArSize] = { 0 };
          int arr_separation_prime[ArSize] = { 0 };
          if (prime(j) == 100)
          prime_factor(j, arr_prime);
          if (arr_prime[k] >= 10)
          k = digit_separation(k, arr_prime[k], arr_separation_prime);
          arr_separation_prime[k] = arr_prime[k];
          if (arr_add(arr_separation_prime) == arr_add(arr_separation))
          arr_prime[i] = 0;
          arr_separation_prime[i] = 0;
         void prime_factor(int num, int *array)
         int prime(int num)
  • SmithNumbers/신재동 . . . . 13 matches
         const int MAX_PRIME_NUMBER = 100000;
         int MAIN_PRIME_NUMBER[MAX_PRIME_NUMBER] = {0,};
         void makePrimeNumbers();
         void makePrimeNumbers()
          int primeCount = 0;
          MAIN_PRIME_NUMBER[primeCount++] = 2;
          for (int i = 3; primeCount < MAX_PRIME_NUMBER; i += 2)
          for (int j = 0; j < primeCount; j++)
          if (i % MAIN_PRIME_NUMBER[j] == 0)
          else if (i / MAIN_PRIME_NUMBER[j] <= MAIN_PRIME_NUMBER[j])
          MAIN_PRIME_NUMBER[primeCount++] = i;
          int prime = 1;
          for(int i = 0; i < MAX_PRIME_NUMBER; i++)
          if(testNumber % MAIN_PRIME_NUMBER[i] == 0)
          prime = MAIN_PRIME_NUMBER[i];
          return prime;
          int prime;
          prime = factorization(testNumber);
          if(prime == 1)
          testNumber /= prime;
  • 소수구하기 . . . . 12 matches
         #define MAX_PRIME 5*DECIMAL
         static int primeArr[1*DECIMAL] = {2, };
         static int i, j, flag, primeArr_p, limit, count = 0;
          primeArr_p = 1;
          for (i = 3; i < MAX_PRIME; i += 2) {
          for (j = 0;primeArr[j] <= limit;j++){
          if (i % primeArr[j] == 0) {
          primeArr[primeArr_p++] = i;
          printf("%d 이하 소수n",MAX_PRIME);
          printf("소수 %d 개 발견n",primeArr_p);
         || Upload:prime_50000.JPG || Upload:prime_500000.JPG || Upload:prime_5000000.JPG || Upload:prime_50000000.JPG ||
  • ACM_ICPC/2013년스터디 . . . . 10 matches
          * queue - [http://211.228.163.31/30stair/prime_path/prime_path.php?pname=prime_path 소수 길]
          * graph, dfs - [http://211.228.163.31/30stair/danji/danji.php?pname=danji 단지 번호 붙이기], [http://211.228.163.31/30stair/orders/orders.php?pname=orders orders], [http://211.228.163.31/30stair/bugslife/bugslife.php?pname=bugslife 짝 짓기], [http://211.228.163.31/30stair/sprime/sprime.php?pname=sprime 슈퍼 소수], [http://211.228.163.31/30stair/snail_trails/snail_trails.php?pname=snail_trails 달팽이]
          * 참고문제 prime_path [http://211.229.66.5/30stair/prime_path/prime_path.php?pname=prime_path]
  • FactorialFactors/이동현 . . . . 5 matches
          ArrayList<Integer> prime = new ArrayList<Integer>();
          boolean isPrime(int num){
          for(int k=0;k<prime.size();k++){
          if(num%prime.get(k)==0)
          prime.add(2);
          if (j == 7 && isPrime(num) == true) {
          prime.add(num);
  • 소수구하기/상욱 . . . . 4 matches
          int primeNumber[100000];
          primeNumber[0] = 2;
          bool isPrimeNumber = true;
          if ( i % primeNumber[j] == 0 ) {
          isPrimeNumber = false;
          if (isPrimeNumber) {
          primeNumber[arrLength++] = i;
          isPrimeNumber = true;
  • SmithNumbers/문보창 . . . . 3 matches
         int sum_digit_prime_factor(int n);
          if (sum_digit_number(i) == sum_digit_prime_factor(i))
         int sum_digit_prime_factor(int n)
          int sumDigitPrimeFactor = 0;
          sumDigitPrimeFactor += 2;
          sumDigitPrimeFactor += sum_digit_number(i);
          if (sumDigitPrimeFactor == 0 || n == 2)
          sumDigitPrimeFactor += sum_digit_number(temp);
          return sumDigitPrimeFactor;
  • 새싹교실/2012/주먹밥 . . . . 3 matches
          * prime 넘버 찾는 알고리즘 구하기.
          ///prime 넘버는 1과 자신을 제외하고 나눠지지 않는 수.
          System.out.println(i + "is prime Number!");
  • ErdosNumbers . . . . 2 matches
         ''Smith, M.N., Martin, G., Erdos, P.: Newtonian forms of prime factors matrices''
         Smith, M.N., Martin, G., Erdos, P.: Newtonian forms of prime factor matrices
  • [Lovely]boy^_^/USACO/PrimePalinDromes . . . . 2 matches
         ifstream fin("pprime.in");
         ofstream fout("pprime.out");
         bool IsPrime(const int& n);
         void FillPrimeList(const int& n, const int& m);
          if(IsPrime(i))
         bool IsPrime(const int& n)
  • ACM_ICPC/2011년스터디 . . . . 1 match
          * 하루 전날까지 표를 보신 분들은 알겠지만 원래 하려던건 RSA Factorization이었는데 문제가 문제가 있더군요(??). 그래서 어느 조건에 맞춰야 Accept가 될지 알 수도 없고 괜히 168명의 사람들만 도전한거 같지는 않아서 일단은 pass하고 다른 문제를 풀었습니다. 기회가 되면 다음엔 prime을 이용한 문제를 좀 풀어보고 싶어요. 물론 Factorization의 특성상 시간이 오래 걸리는 점이 있어서 좋은 알고리즘을 고안해야 겠지만.. World Cup 문제에 대한 후기는.. 음.. 골라놓고 막 머리싸매고 풀어보니 별거 아닌 문제라 웬지 모임에서 학우들의 원성을 살것만 같은 느낌이에요. 엉엉..ㅠㅠ - [지원]
  • ErdosNumbers/황재선 . . . . 1 match
          "Newtonian forms of prime factor matrices";
  • PrimeNumberPractice . . . . 1 match
         void CalculatePrimeNumber(int scope[], int length);
         void PrintPrimeNumber(int scope[], int lengh);
         // this program print prime number in scope 1 to 2000
          CalculatePrimeNumber(targetNumberScope, scope);
          PrintPrimeNumber(targetNumberScope, scope);
         void CalculatePrimeNumber(int scope[], int length) {
         void PrintPrimeNumber(int scope[], int length) {
         public class PrimeNumberTest {
          private static void CalculatePrimeNumber() {
          CalculatePrimeNumber();
  • SummationOfFourPrimes . . . . 1 match
         == About[SummationOfFourPrimes] ==
          || [문보창] || C++ || . || [SummationOfFourPrimes/문보창] || O ||
          || [김회영] || C++ || ? || [SummationOfFourPrimes/김회영] || . ||
          || [곽세환] || C++ || ? || [SummationOfFourPrimes/곽세환] || O ||
          || [1002] || Python || 50분(이후 튜닝 진행. 총 2시간 46분 23초) || [SummationOfFourPrimes/1002] || X (5.7s) ||
         [http://www.n2n.pe.kr/util/find_prime.php 소수판정기]로 답을 확인해볼 수 있겠네요. --[Leonardong]
  • zennith/source . . . . 1 match
         /* prime2.c */
         #define MAX_PRIME 50000
          for (i = 3; i < MAX_PRIME; i += 2) {
  • 데블스캠프2011/다섯째날/Cryptography . . . . 1 match
          * http://www.bigprimes.net
  • 새싹교실/2011/씨언어발전/5회차 . . . . 1 match
         int isPrime(int number)
          if (isPrime(i)==TRUE) printf(“%d\n”,i);
         그리고 array를 이용하여 학생들 시험점수의 총합과, 평균, 모든학생의 총합과, 총평균을 구하는 코딩을 해보았다. 또한, 소수(prime number)를 구하는 함수를 배웠다.
  • 소수구하기/zennith . . . . 1 match
         #define MAX_PRIME 50000
          for (i = 3; i < MAX_PRIME; i += 2) {
          printf("#%d prime numbers.\n", count);
Found 23 matching pages out of 7540 total pages (5000 pages are searched)

You can also click here to search title.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
Processing time 0.3019 sec