Răspuns :
Răspuns:
Salut!
Explicație:
La 4. nu sunt sigur daca am inteles bine,
de ex 153 da? 1*1*1+5*5*5+3*3*3=153 => 153 = 153
------------------------------
#include <iostream>
#include <cmath>
using namespace std;
int sum(int n)
{
int s=0;
while(n!=0)
{
s=s+pow(n%10,3);
n=n/10;
}
return s;
}
int main()
{
long long n,i,s=0;
cin>>n;
while(n!=0)
{
if(sum(n)==n)
cout<<sum(n)<<' ';
n--;
}
}
------------------------------
5.
#include <iostream>
using namespace std;
int prim(int n)
{
if(n<2)
return 0;
if(n==2)
return 1;
if(n%2==0)
return 0;
int d;
for(d=3;d*d<=n;d=d+2)
if(n%d==0)
return 0;
return 1;
}
int pal(int n)
{
int ogl=0;
while(n!=0)
{
ogl=ogl*10+n%10;
n=n/10;
}
return ogl;
}
int main()
{
int a,b,i,ogl=0;
cin>>a>>b;
a--;
do
{
a++;
if(pal(a)==a)
if(prim(a)==1)
cout<<a<<' ';
}while(a!=b);
return 0;
}
------------------------------
6.
#include <iostream>
using namespace std;
int main()
{
int n, div;
cin>>n;
div=2;
cout<<1<<" ";
while(div<=n/2)
{
if(n%div==0)
cout<<div<<" ";
div++;
}
cout<<n<<" ";
return 0;
}
------------------------------
Toate ar trebui sa fie corecte + le-am facut cu while si do while