1
#include <iostream>
using namespace std;
int main()
{
int a, suma = 0;
cin >> a;
while (a > 0)
{
suma = suma + a % 10;
a = a / 10;
}
cout << suma;
return 0;
}
2.
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
for (int i = 2; i <= a/2; i++)
{
if (a % i == 0)
{
cout << i << " ";
}
}
return 0;
}
3
Algoritmul lui Euclid
#include <iostream>
using namespace std;
int main()
{
int a, b, r, cmmdc;
cin >> a >> b;
r = a % b;
while (r !=0)
{
a = b;
b = r;
r = a % b;
}
cmmdc = b;
cout << cmmdc;
return 0;
}