-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrime_Numbers_11253001_Tayfun_Adakoglu.cpp
More file actions
166 lines (138 loc) · 3.86 KB
/
Copy pathPrime_Numbers_11253001_Tayfun_Adakoglu.cpp
File metadata and controls
166 lines (138 loc) · 3.86 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*//********************************************SORU-1************************************************
#include <stdio.h>
#include <conio.h>
bool asalsayi(int );
void main()
{
int N,counter;
counter =0;
printf("Enter the number:");
scanf_s("%d", &N);
while (N < 0)
{
printf("Enter a proper(positive) number please:");
scanf_s("%d", &N);
}
printf("Girdiginiz sayi %d'e kadar olan asal sayilar:\n", N);
for (int i = 2; i <= N; i++)
{
if(asalsayi(i)) // asal sayi ise yazdýrma kontrolü
{
counter++; // asal sayý sayacý
printf("%d ", i);
}
}
printf("\nAdet: %d", counter);
_getch();
}
bool asalsayi(int N)
{
for (int i = 2; i <= N-1 ; i++)
{
if(N % i == 0)
return false;
}
return true;
}
//*********************************************SORU-1***********************************************/
/*////////////////////////////////////////// SORU -2 ////////////////////////////
#include <stdio.h>
#include <conio.h>
void main()
{
double A = 10000000; // %25
double B = 40000000; // %12 increase rates: artýþ oranlarý
// a ülkesi b yi kaç yýl sonra geçer
int yil = 0;
///////////////////WHILE ILE////////////////////////
printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
while(A <= B) // 1,3 // 2,1 artýþ hýzý ; 1,3,5,7 : 3,4,5,6
{
A = A + A*(double)25/100;
B = B + B*(double)12/100;
yil++;
printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
}
///////////////////FOR ILE////////////////////////
//
//printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
//for (yil = 1; A <= B; yil++)
//{
// A = A + A*(double)25/100;
// B = B + B*(double)12/100;
// printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
//}
//yil--; // bir tane fazla seker
////////////////////DOWHILE ///////////////////////
//printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
//do
//{
//
// A = A + A*(double)25/100;
// B = B + B*(double)12/100;
// yil++;
// printf("A'nin nufusu: %0.0Lf\tB'nin nufusu : %0.0Lf\tYil: %d\n", A,B,yil);
//}
//while ( A <= B); // 1,3 // 2,1 artýþ hýzý ; 1,3,5,7 : 3,4,5,6 TESTING
//TEZZZZZZZZZZZZZZZZZZZZZZZZZZ
printf("\nA ulkesinin nufusu B ulkesininkini %d yil sonra gecer.", yil);
_getch();
}
/////////////////////////////////// SORU -2 ////////////////////////////////////*/
/*//////////////////////////////////////////////SORU -3 ///////////////////////////////////
#include <stdio.h>
#include <conio.h>
void main()
{
int sum,counter;
counter=0;
printf("1 ve 1000 arasindaki mukemmel sayilar\n_________________________________________\n");
for (int i = 1; i < 1000; i++)
{
sum = 0;
for (int j = 1; j < i; j++)
{
if(i % j == 0)
sum+=j;
}
if(i == sum)
printf("Line %d: %d bir mukemmel sayidir.\n", ++counter,i);
}
_getch();
}
///////////////////////////////////////SORU-3//////////////////////////////////*/
/*//////////////////////////////////4.SORU-SON//////////////////////////////////////
#include <stdio.h>
#include <conio.h>
bool asalsayi(int N);
void main()
{
int counter=0;
printf("Iki basamakli ikiz asal sayilar listesi\n");
int ix,jy; // THE GREATEST COUPLE
for (int i = 10; i <= 99; i++)
{
for (int j = 10; j <= 99; j++)
{
if(asalsayi(i) && asalsayi(j) && (i-j)==2)
{
printf("Line %d: %d ve %d ikiz asal sayilardir.\n", ++counter,i,j);
ix = i;
jy = j;
}
}
}
printf("________________________________________\n");
printf("%d ve %d en buyuk ikiz asal sayi ciftidir.", ix,jy);
_getch();
}
bool asalsayi(int N)
{
for (int i = 2; i <= N-1 ; i++)
{
if(N % i == 0)
return false;
}
return true;
}
////////////////////////////4.SORU-SON///////////////////////////////////*/