Amazon banner

Sunday, 16 September 2012

PROGRAM TO VERIFY PRIME NUMBERS PROPERTY


/***********************************************************************/
/* PROGRAM TO VERIFY PRIME NUMBERS PROPERTY                            */
/* AUTHOR : DEEPAK MAHAKALE 3 YEAR IT SRCOEM                           */
/* BLOG : www.mahakaledeepak.blogspot.com                              */
/***********************************************************************/

#include<stdio.h>
#include<conio.h>

void main() {

  int n, prime, i, j, k, l;
  clrscr();
  printf("\n\t PROGRAM TO VERIFY PRIME NUMBERS PROPERTY");
  printf("\n\n\t Enter any number : ");
  scanf("%d", & n);

  printf("\n\t PRIME NO.  REMAINDER 1 WHEN DIVIDED BY 4 ");
  for (i = 2; i < n; i++) {
    prime = 1;
    for (j = 2; j < i; j++) {
      if (i % j == 0)
        prime = 0;
    }
    if (prime == 1) {
      // printf("\n\t %d",i);
      if (i % 4 == 1) {
        for (k = 1; k < n; k++) {
          for (l = 1; l < n; l++) {
            if ((k * k) + (l * l) == i) {
              printf("\n\t %d  -->  %d + %d = %d\ti.e %d SQ + %d SQ  ", i, k * k, l * l, i, k, l);
            }
          }
        }
      }
    }
  }
  printf("\n\n\n\t BY - DEEPAK MAHAKALE");
  getch();

}

No comments:

Post a Comment