Revision: 38222
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 29, 2010 02:10 by CyKy
Initial Code
/* Indicativul lui Euler! */ #include <stdio.h> #include <stdlib.h> // Functia CMMDC int cmmdc(int n,int m){ int r; r=n%m; while(r!=0){ n=m; m=r; r=n%m; } return m; } //Program principal int main() { int n,i,contor=0,v[100],j=1,v1[10000],k,l=0,raspuns=0; printf(">Cate numere introduceti? n="); scanf("%d",&n); printf(">Introduceti numerele: \n"); for(i=0;i<n;i++){ printf(">%d numar:",i+1); scanf("%d",&v[i]); j=1; contor=0; l=0; raspuns=0; //retin valorile mai mici ca V[i] intrun vector V1 while(j<v[i]){ //printf("%d,",j); v1[contor]=j; contor+=1; j++; } //parcurg elementele vectorului V1 for(k=0;k<contor;k++){ //printf(">v1[%d]=%d \n",k,v1[k]); if(cmmdc(v[i],v1[k])==1){ //<---- testez daca V1 au cmmdc=1 adik dak sunt prime intre ele l+=1; //<---- incrementez daca am gasit un numar care cu V[i] are cmmdc=1 //printf("%d,",v1[k]); } } printf(">F(%d)=%d,",v[i],l); while(l%2==0){ l/=2;//-->impartiri consecutive la 2 } if(l==1){//-->daca catul este 1 inseamna ca este o putere a lui 2 printf("este o putere a lui 2\n"); } else{ printf("nu este o putere a lui 2\n"); } } system("pause"); return 0; }
Initial URL
Initial Description
Initial Title
Euler`s function
Initial Tags
function
Initial Language
C