Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. // tema-or-e5.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. bool prim(int s)
  8. {
  9.     int i;
  10.     for(i=2;i<=s/2;i++)
  11.         if(s%i==0)
  12.             return 0;
  13.     return 1;
  14. }
  15.  
  16. int _tmain(int argc, _TCHAR* argv[])
  17. {
  18.     int n,j=1,i=1,s;
  19.     printf("Dati n: ");
  20.     scanf("%d", &n);
  21.     printf("\n %d %d ",i, j);
  22.     while(n)
  23.     {  
  24.         s=i+j;
  25.         if(prim(s)){
  26.             printf("%d ", s);
  27.             n--;}
  28.         i=j;
  29.         j=s;       
  30.     }
  31.     scanf("%d",j);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement