0% found this document useful (0 votes)
9 views2 pages

Mainn

The document contains three code snippets that demonstrate how to check if two numbers are prime to each other, multiply the odd digits of a number, and sum the digits of a number respectively.

Uploaded by

Blueix Dragon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Mainn

The document contains three code snippets that demonstrate how to check if two numbers are prime to each other, multiply the odd digits of a number, and sum the digits of a number respectively.

Uploaded by

Blueix Dragon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//se citesc 2 nr sa se verifice daca sunt prime intre ele

#include <iostream>
using namespace std;
int main()
{
int a,b,cmmdc;
cin>>a>>b;

while(a!=b)
{
if(a>b)a=a-b;
else b=b-a;

}
cmmdc=a;
if (cmmdc==1)
cout<<"nr sunt prime intre ele";
else cout<<"nr nu sunt prime intre ele";

return 0;
}

//produsul cifrelor impare ale lui n


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n,p,u;
cin>>n;
p=1;
while (n!=0)
{
u=n%10;
if(u%2==1) p=p*u;
n=n/10;

}
cout<<p;
return 0;
}

//suma cifrelor lui n


#include <iostream>
using namespace std;
int main()
{
int n,u,s;
s=0;
cin>>n;
while(n!=0)
{
u=n%10;
s=s+u;
n=n/10;

}
cout<<s;
return 0;
}

You might also like