All pastes #410464 Raw Edit

Miscellany

public text v1 · immutable
#410464 ·published 2007-03-26 12:21 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>

bool CzyPierwsza(int n) {
bool wynik = 0;
              if(n > 1) {
              int p = 0;
                   for(int i = 2; i < n; ++i) {
                           if(n % i == 0) {
                           ++p;
                           }
                   }

                   if(p == 0) {
                   wynik = 1;
                   }
              }
return wynik;
}

int main(int argc, char *argv[])
{
  int a = 0;
  bool p = 0;
  printf("Podaj liczbe: ");
  scanf("%i", &a);
              if(CzyPierwsza(a)) {
              printf("Liczba %i jest pierwsza\n", a);
              }
              else {
              printf("Liczba %i nie jest pierwsza\n", a);
              }

  system("pause");
  return 0;
}