• Pada Algoritma pencarian banyak yang bisa kita temukan atau gunakan. Ada Merge Sort, Quick Sort, Bubble Sort, dan...
  • Pada dasarnya algoritma searching banyak kita jumpai. Apalagi hanya untuk mencari nilai minimum dan nilai maximum...
  • Kalian pasti sudah tahu apa itu Deret Fibonacci, ya benar. (Padahal gak jawab). Tetapi pada pembahasan kali ini kita akan membuar program...
  • Metoda Pencarian Biner ( Binary Search) hanya bisa diterapkan jika data array sudah terurut. Pengurutan Array bisa menggunakan jenis sorting ...
  • Salah satu contoh tipe algoritma brute force lainnya adalah linear search (pencarian berurutan), Dikatakan demikian karena algoritma ini menggunakan ...

Wednesday, April 20, 2011

Prime Numbers: Determining the Type A Numbers


In the discussion this time I want to discuss the issue of primes. What is a prime number? Prime number is a positive integer more than one and the number is no trace if divided by one and the number itself. From these definitions we can make inferences primes are numbers that are only produced no trace of value if divided by two times, divided by one and the number itself. Immediately, in the example algorithms and programs. Then we can make the algorithm as follows :

Algoritma Prime Numbers
                {Specifies the type of an input number, primed or not primed}
Deklarasi
                 a : integer (inialisasi)
       x : integer (input)
Deskripsi
                Read (x)
      a  <--  0
      for 1 to x do {
      if (x % i == 0) then a++
      }
      if (a == 2) then write (“bilangan prima”)
      else then write (“bukan bilangan prima”)

Writing functions in a program like this (in C + +) : 

 
For a complete C + + program you can download here dyas sembilanpoepoeh.cpp
For a complete  Java  program you can download here dyas sembilanpoepoeh.java

Jadilah yang pertama mengomentari

Post a Comment

Tutorial Algorithm and Programming ©Template Blogger Green by Dicas Blogger.

To Up