There are many ways to create a prime numbers. However, the time constraints will reflect your skill to create an algorithm. Whereas I am a student of computer science, the algorithm should meet time efficiency. I am sure that all of you already had project about prime numbers. In the following examples, I will be using the Python2.5 programming language to demonstrate such algorithms and compare their efficiencies. Later I will also update it into C/C++ and Java languages.

The first algorithm we shall consider will begin with the integer 2 and proceed to select each successive integer as a potential prime, (pp), checking for primacy by testing to see if it can be factored by any previously identified primes, then storing each newly verified prime in a prime set (ps) array.

pp=2
ps=[pp]
lim=raw_input(“\nGenerate prime numbers up to what number? : “)
while pp<int(lim):
pp+=1
test=True
for a in ps:
if pp%a==0: test=False
if test: ps.append(pp)
return ps
Note: The code given above does not constitute a complete program. See Appendix A for a complete program including a user interface.
Such a rudimentary algorithm takes a strictly brute force approach to effectively achieve the goal of identifying each prime number and storing it in an array. I am sure you would agree that this is also about the least efficient means of generating prime numbers.

Hi,

Having trouble with your Mafia Wars, Pet Society, Kung Fu Pets, Restaurant City, Mouse Hunt, or any other games on facebook ?

At the first time when I saw the main page of this site . I was fascinating with the header menus. How came one systems can make a GOD FATHER bot systems ?. Then,  I try to buy it. Because the price is very cheap just $37.00 !!

After that, I unpack the sources. The contents are very worthed. Now, i can make my own bots, and then I beat all of my friends !!

I believe this bot systems is the best ever facebook BOT systems.

Try it now..This is not a bullshit !! You can also get your money back if you cannot beat your own friends.

 

Visit fb-bot.com NOW !! LIMITED OFFER !!

 

 

Factorial – Recursive.html

#include <iostream>

using namespace std;

long fibonacci_version_1( long );
long fibonacci_version_2( long );

long fibonacci_version_3( long );

int main() {   

    int start = 0;

	int end = 0;
	start = time(NULL);

    long fibo = fibonacci_version_1(-1);
    end = time(NULL);

    cout << "Time = " << end - start << endl;
    cout << "Fibo : " << fibo << endl;


    system("pause");
    return 0;
}

long fibonacci_version_1( long n ) {

     // Check if the n is negative number, return 1
     if( n < 0 )
         return 1;


     switch( n ) {
        case 0:
        case 1:

           return n;
           break;
        default:
           return fibonacci_version_1( n - 1 ) + fibonacci_version_1( n  - 2 );
           break;

     }// end of switch

}// end of fibonacci function

long fibonacci_version_2( long n ){
     // Check if n equal to zero or one return to n it self

     if( ( n == 0 ) || ( n == 1 ) )

         return n;
     else
         return fibonacci_version_2( n - 1 ) + fibonacci_version_2( n - 2 );


}// end of fibonacci_version2 function

long fibonacci_version_3( long n ){

     if( 0 == n )

         return n;
     else if( 1 == n )

         return n;
     else
         return fibonacci_version_3( n - 1 ) + fibonacci_version_3( n - 2 );


}



/**
      This is a common factorial function using recursive.
      Compiled with Dev C++ 4.9.9.2
      Swiss German University
      ICT – 2
*/

#include <iostream>

using namespace std;

// Function Prototype
long factorial( long );

int main() {
     cout << ” The result is come from N! = (N-1)*(N-2)*…*(N equal 1) “ << endl;
     for(int i = 0; i <= 10; i++ ) {
         cout << i << “! = “;
         cout << factorial(i) << endl;
     }

     system(“pause”);
     return 0;
}// end of main function

/**
    @param long – number
           A “n” factorial number.
    @return
           If the number is 1 or less than 1 return 1.
           Otherwise, it will be return a result
*/

long factorial( long number ) {
      if( number <= 1 )
          return 1;
      else //Recursive
          return ( number * factorial( number – 1 ) );
}// end of factorial function


Dalam proses pengorganisasian dan pemrosesan data dalam jumlah banyak dapat menggunakan suatu array.

Masalah yang kita jumpai dalam menggunakan array :

1. Besar dari array adalah terbatas

2. Array tidak terurut (Unsorted array) mencari menggunakan sebuah nilai cenderung lambat.

3. Akan tetapi, bila array yang urut, untuk menambah dan menghapus cenderung lambat.

Linked List : Sebuah list dari item, dimana urutan dari node (item) itu sendiri di atur oleh memory address dalam komputer kita, yang dinamakan Link.

Perhatikan gambar di bawah ini:

Satu node merupakan data dan sebuah link. Data berisikan suatu variable/angka dan link sendiri berisikan suatu alamat / address yang menunjuk address yang lain.

Perhatikan gambar di atas dengan cermat. Lalu bayangkan bagaimana bila terdapat lebih dari satu node. Maka akan menjadi di bawah ini:

Pada di atas perhatikan arah panah dari ujung kiri yaitu bagian ‘head / kepala’ sampai dengan paling pojok kanan. Pada bagian pojok kanan arah panah menunjuk ke bawah, itu berarti link yang berada di item/node terakhir itu menunjuk ke alamat NULL / tidak terisi dengan alamat address/ yang lebih mudah lagi tidak menunjuk ke alamat address yang lain lagi.

Andaikata node pertama pada lokasi memory 1200 dan node kedua pada lokasi memori 1575.

Karena dalam tiap node itu terdapat dua komponen (data dan link). Oleh karena itu, kita perlu sebuah struct or class.

struct nodeType { int info; nodeType * link; };

Penjelasan kode diatas:
Kita membuat satu nodeType yang didalamnya berisi data info dan pointer link.
Info bertipe integer. nodeType * link menunjuk address struct nodeType selanjutnya.

Okay, Let’s take some practice… Okay, mari kita berlatih dahulu..

Warna kuning adalah alamat address / link itu sendiri yang bertipe pointer.
Warna biru adalah info yang bertipe integer.

head
head -> link
head -> info
head -> link -> info
head -> link -> link -> info
head -> link -> link -> link
head -> link -> link -> link -> link

Follow

Get every new post delivered to your Inbox.