-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
83 lines (59 loc) · 1.5 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
using namespace std;
int main()
{
/// 1
int a;
cout << "Ingrese un numero" << endl;
cin >> a;
while(a%2==0 & a%3==0)
cout << a << " No es primo" << endl;
for(int a=1;a<=10;a++)
if(a%2==0 or a%3==0)
cout << a << " No es primo" << endl;
else
cout << a << " Es primo" << endl;
/// 2
for(int i=1;i<100;i++)
if(i%2==0 or i%3==0)
cout << i << " No es primo " << endl;
else
cout << i << " Es primo" << endl;
int i=1;
while(i<100)
if(i%2==0 & i%3==0)
cout << i << " No es primo" << endl;
i++;
else
cout << i << " Es primo" << endl;
i++;
///3
int a = 0;
int b = 0;
cout<<"Rango de busqueda: ";
cin>>b;
for(int i=1;i<= b;i++){
if(i%2 == 0){
for(int j=(i/2);j>=1;j--)
if( i%j==0)
a=a+j;
}
if(a==i)
cout<< a << " Es un numero perfecto " <<endl;
a = 0;
}
int numero;
int suma=0;
int divisor=1;
cout << ("Numeros") << endl;
while(divisor<numero)
if(numero%divisor==0)
cout << ("%d",divisor) << endl;
suma=suma+divisor;
divisor++;
if(numero==suma)
cout << (" Es un numero perfecto");
else
cout << (" No es un numero perfecto");
return 0;
}