Split variable to get the last string as a new variable - stata

I have a large dataset of 5,000 observations and a subset of my data looks as follows:
AandB
1 222 454 213.51 59.15%
444 630 789.46 6.15%
2 374 798 807.69 32.00%
304 738 263.59 19.95%
177 641 617.86 18.07%
857 937 842.27 51.97%
973 127.33 0.03%
86 205 146.62 1.18%
I need two variables, A and B out of this one variable.
For example, 1 222 454 213.51 should be in column A as 1222454213.51and corresponding observation in variable B should be 59.15%
There is a double-space separating what values I want in A, and what I want in B in the raw data.
Hence, I need:
A B
1222454213.51 59.15%
444630789.46 6.15%
2374798807.69 32.00%
304738263.59 19.95%
177641617.86 18.07%
857937842.27 51.97%
973127.33 0.03%
86205146.62 1.18%
I was able to obtain variable A with the following:
generate A = reverse(substr(reverse(AandB),strpos(reverse(AandB), " "), . ))
replace A = subinstr(A, " ", "", .)
However, I have trouble extracting the percentage numbers.

Another way to advance is to peel off the last "word" (Stata sense) first:
clear
input str42 AandB
"1 222 454 213.51 59.15%"
"444 630 789.46 6.15%"
"2 374 798 807.69 32.00%"
"304 738 263.59 19.95%"
"177 641 617.86 18.07%"
"857 937 842.27 51.97%"
"973 127.33 0.03%"
"86 205 146.62 1.18%"
end
generate B = word(AandB, -1)
generate A = trim(subinstr(AandB, B, "", .))
list AandB A B, separator(0)
+------------------------------------------------------+
| AandB A B |
|------------------------------------------------------|
1. | 1 222 454 213.51 59.15% 1 222 454 213.51 59.15% |
2. | 444 630 789.46 6.15% 444 630 789.46 6.15% |
3. | 2 374 798 807.69 32.00% 2 374 798 807.69 32.00% |
4. | 304 738 263.59 19.95% 304 738 263.59 19.95% |
5. | 177 641 617.86 18.07% 177 641 617.86 18.07% |
6. | 857 937 842.27 51.97% 857 937 842.27 51.97% |
7. | 973 127.33 0.03% 973 127.33 0.03% |
8. | 86 205 146.62 1.18% 86 205 146.62 1.18% |
+------------------------------------------------------+
If you do want A to be regarded as specifying some very big numbers, then
generate double A2 = real(subinstr(A, " ", "", .))
is one way forward. Measuring to 12 significant figures implies that you are in astronomy (and perhaps the first 6 digits are good) or in economics (and perhaps the first digit is reliable).

The following works for me:
clear
input str50 AandB
"1 222 454 213.51 59.15%"
"444 630 789.46 6.15%"
"2 374 798 807.69 32.00%"
"304 738 263.59 19.95%"
"177 641 617.86 18.07%"
"857 937 842.27 51.97%"
"973 127.33 0.03%"
"86 205 146.62 1.18%"
end
generate A = subinstr(substr(AandB, 1, strpos(AandB,"%")-6)," ", "", .)
generate B = subinstr(substr(AandB, strpos(AandB,"%")-6, .)," ", "", .)
list, separator(0)
+---------------------------------------------------+
| AandB A B |
|---------------------------------------------------|
1. | 1 222 454 213.51 59.15% 1222454213.51 59.15% |
2. | 444 630 789.46 6.15% 444630789.46 6.15% |
3. | 2 374 798 807.69 32.00% 2374798807.69 32.00% |
4. | 304 738 263.59 19.95% 304738263.59 19.95% |
5. | 177 641 617.86 18.07% 177641617.86 18.07% |
6. | 857 937 842.27 51.97% 857937842.27 51.97% |
7. | 973 127.33 0.03% 973127.33 0.03% |
8. | 86 205 146.62 1.18% 86205146.62 1.18% |
+---------------------------------------------------+
EDIT:
On second thought this can be simplified to the following:
generate A = subinstr(substr(AandB, 1, strpos(AandB," "))," ", "", .)
generate B = subinstr(substr(AandB, strpos(AandB," "), .)," ", "", .)

One way would be:
split AandB, p(" ")
rename AandB1 A
rename AandB2 B
replace A = subinstr(A, " ", "", .)
list, separator(0)
+---------------------------------------------------+
| AandB A B |
|---------------------------------------------------|
1. | 1 222 454 213.51 59.15% 1222454213.51 59.15% |
2. | 444 630 789.46 6.15% 444630789.46 6.15% |
3. | 2 374 798 807.69 32.00% 2374798807.69 32.00% |
4. | 304 738 263.59 19.95% 304738263.59 19.95% |
5. | 177 641 617.86 18.07% 177641617.86 18.07% |
6. | 857 937 842.27 51.97% 857937842.27 51.97% |
7. | 973 127.33 0.03% 973127.33 0.03% |
8. | 86 205 146.62 1.18% 86205146.62 1.18% |
+---------------------------------------------------+

Related

Filling missing observations with equal parts of the existing observation (Stata)

I would like to fill the missing observation(s) with the values of the next cell and distribute it equally over the missing rows.
For example using data from below, I would fill value for 2004m1 and 2004m2 with 142 and also replace value for 2004m3 with 142, as we fill two missings (142 = 426/3). For 2005m7/m8 it would be 171 etc. I am able to fill the missings with revered sorting and carryforward, however I cannot figure out how to redistribute the values, especially that the number of rows that I try to fill can vary and it is not simple [_n+1].
My try to fill the values (but this does not redistribute):
carryforward value, gen(value_filled)
Example data set:
date_m value
2005m12 56
2005m11 150
2005m10 190
2005m9 157
2005m8 342
2005m7 .
2005m6 181
2005m5 151
2005m4 107
2005m3 131
2005m2 247
2005m1 100
2004m12 77
2004m11 181
2004m10 132
2004m9 153
2004m8 380
2004m7 .
2004m6 174
2004m5 178
2004m4 104
2004m3 426
2004m2 .
2004m1 .
Expected result
date_m value
2005m12 56
2005m11 150
2005m10 190
2005m9 157
2005m8 171
2005m7 171
2005m6 181
2005m5 151
2005m4 107
2005m3 131
2005m2 247
2005m1 100
2004m12 77
2004m11 181
2004m10 132
2004m9 153
2004m8 190
2004m7 190
2004m6 174
2004m5 178
2004m4 104
2004m3 142
2004m2 142
2004m1 142
Thanks for your data example, which is helpful, but as detailed in the Stata tag wiki and on Statalist an example using dataex is even better. Date and time variables are especially awkward otherwise.
You allude to carryforward, which is from SSC and which many have found useful. Having written the FAQ on this accessible here my prejudice is that most such problems yield quickly and directly to sorting, subscripting and replace. Your problem is trickier than most in including a value to be divided after an unpredictable gap of missing values.
This works for your example and doesn't rule out a simpler solution.
* Example generated by -dataex-. To install: ssc install dataex
clear
input float date int mvalue
551 56
550 150
549 190
548 157
547 342
546 .
545 181
544 151
543 107
542 131
541 247
540 100
539 77
538 181
537 132
536 153
535 380
534 .
533 174
532 178
531 104
530 426
529 .
528 .
end
format %tm date
gsort -date
gen copy = mvalue
replace copy = copy[_n-1] if missing(copy)
gen gap = missing(mvalue[_n+1]) | missing(mvalue)
replace gap = gap + gap[_n-1] if gap == 1 & _n > 1
sort date
replace gap = gap[_n-1] if inrange(gap[_n-1], 1, .) & gap >= 1
gen wanted = cond(gap, copy/gap, copy)
list , sepby(gap)
+----------------------------------------+
| date mvalue copy gap wanted |
|----------------------------------------|
1. | 2004m1 . 426 3 142 |
2. | 2004m2 . 426 3 142 |
3. | 2004m3 426 426 3 142 |
|----------------------------------------|
4. | 2004m4 104 104 0 104 |
5. | 2004m5 178 178 0 178 |
6. | 2004m6 174 174 0 174 |
|----------------------------------------|
7. | 2004m7 . 380 2 190 |
8. | 2004m8 380 380 2 190 |
|----------------------------------------|
9. | 2004m9 153 153 0 153 |
10. | 2004m10 132 132 0 132 |
11. | 2004m11 181 181 0 181 |
12. | 2004m12 77 77 0 77 |
13. | 2005m1 100 100 0 100 |
14. | 2005m2 247 247 0 247 |
15. | 2005m3 131 131 0 131 |
16. | 2005m4 107 107 0 107 |
17. | 2005m5 151 151 0 151 |
18. | 2005m6 181 181 0 181 |
|----------------------------------------|
19. | 2005m7 . 342 2 171 |
20. | 2005m8 342 342 2 171 |
|----------------------------------------|
21. | 2005m9 157 157 0 157 |
22. | 2005m10 190 190 0 190 |
23. | 2005m11 150 150 0 150 |
24. | 2005m12 56 56 0 56 |
+----------------------------------------+

Merging two variables

I have the following data:
I want to turn the data in the upper panel into the data in the lower one.
For each origin group, I want to add one line with destination value -1, and var value from varnew.
I tried to find if there is a command which adds one row so that I can do something like:
bysort origin: addrow
However, it seems there isn't any such thing.
Using your toy example data:
clear
input destination origin var varnew
0 111 124 .
111 111 671 168
0 222 623 .
222 222 768 865
end
list, abbreviate(15)
+-------------------------------------+
| destination origin var varnew |
|-------------------------------------|
1. | 0 111 124 . |
2. | 111 111 671 168 |
3. | 0 222 623 . |
4. | 222 222 768 865 |
+-------------------------------------+
expand 2 if varnew != .
sort origin destination
list, abbreviate(15)
+-------------------------------------+
| destination origin var varnew |
|-------------------------------------|
1. | 0 111 124 . |
2. | 111 111 671 168 |
3. | 111 111 671 168 |
4. | 0 222 623 . |
5. | 222 222 768 865 |
|-------------------------------------|
6. | 222 222 768 865 |
+-------------------------------------+
The following works for me:
bysort origin: replace destination = -1 if destination[_n] == destination[_n+1] & !missing(varnew)
bysort origin: replace var = varnew if var[_n] == var[_n+1] & !missing(varnew)
list destination origin var, abbreviate(15)
+----------------------------+
| destination origin var |
|----------------------------|
1. | 0 111 124 |
2. | -1 111 168 |
3. | 111 111 671 |
4. | 0 222 623 |
5. | -1 222 865 |
|----------------------------|
6. | 222 222 768 |
+----------------------------+

Formatting MMSS in SAS

DATA USCFootballStatsProject;
INPUT OPPONENT $ 1-12 WINORLOSS 13-14 TIMEOFPOSSESSION 15-19 THIRDDOWNCONVERSIONPERCENTAGE 21-26 RUSHINGYARDS;
FORMAT TIMEOFPOSSESSION MMSS.;
CARDS;
UCF 1 24:30 0.125 32
GEORGIA 0 26:59 0.333 43
ALABAMA 0 22:53 0.333 71
TROY 1 31:47 0.333 116
AUBURN 0 28:51 0.167 70
KENTUCKY 1 29:11 0.636 139
VANDERBILT 1 24:50 0.333 132
TENNESSEE 1 32:08 0.353 65
ARKANSAS 1 27:53 0.429 45
FLORIDA 1 25:50 0.300 120
CLEMSON 0 28:12 0.250 167
MISSOURI 0 31:19 0.316 142
MISSSTATE 1 32:39 0.231 81
GEORGIA 0 29:08 0.364 35
WOFFORD 1 24:21 0.417 165
FLOATLANTIC 1 32:39 0.429 200
AUBURN 0 30:20 0.462 109
KENTUCKY 1 31:07 0.538 190
VANDERBILT 1 30:54 0.727 194
TENNESSEE 0 31:33 0.417 165
ARKANSAS 0 23:06 0.333 51
FLORIDA 0 30:31 0.500 135
MTENNESSEE 1 28:17 0.778 154
CLEMSON 1 32:57 0.600 208
HOUSTON 1 33:19 0.500 189
LOUISLFY 1 31:38 0.538 195
GEORGIA 1 30:34 0.091 140
SCSTATE 1 26:53 0.364 223
LSU 0 27:09 0.500 17
MISSSTATE 1 29:39 0.500 123
KENTUCKY 1 29:57 0.462 86
NCAROLINA 1 25:56 0.083 110
VANDERBILT 0 26:36 0.083 26
TENNESSEE 0 36:25 0.438 39
ARKANSAS 0 30:55 0.400 125
FLORIDA 0 25:39 0.167 68
CLEMSON 0 21:23 0.375 80
NCSTATE 1 34:15 0.357 171
VANDERBILT 0 29:58 0.400 92
GEORGIA 0 24:47 0.417 18
WOFFORD 1 31:07 0.636 172
UAB 1 34:59 0.500 158
OLEMISS 1 31:21 0.538 78
KENTUCKY 1 30:43 0.471 74
LSU 0 25:28 0.111 39
TENNESSEE 1 32:30 0.500 101
ARKANSAS 1 29:06 0.417 132
FLORIDA 0 29:50 0.067 53
CLEMSON 0 27:13 0.471 92
IOWA 0 24:06 0.455 43
NCSTATE 1 32:25 0.333 108
GEORGIA 0 34:21 0.353 114
FLOATLANTIC 1 27:50 0.300 287
OLEMISS 1 33:35 0.375 65
SCSTATE 1 27:13 0.538 213
KENTUCKY 1 29:17 0.500 128
ALABAMA 0 31:43 0.474 64
VANDERBILT 1 32:22 0.375 119
TENNESSEE 0 26:35 0.267 65
ARKANSAS 0 27:37 0.500 53
FLORIDA 0 31:21 0.250 61
CLEMSON 1 36:31 0.375 223
CONN 0 24:32 0.200 76
SOUTHERMISS 1 28:52 0.400 224
GEORGIA 1 35:15 0.643 189
FURMAN 1 33:30 0.600 182
AUBURN 0 28:52 0.500 79
ALABAMA 1 27:33 0.545 110
KENTUCKY 0 25:13 0.500 90
VANDERBILT 1 37:21 0.529 129
TENNESSEE 1 28:28 0.538 212
ARKANSAS 0 25:40 0.417 105
FLORIDA 1 40:46 0.500 239
TROY 1 30:49 0.455 212
CLEMSON 1 34:43 0.333 95
AUBURN 0 28:59 0.417 156
FLORIDAST 0 26:32 0.500 139
ECU 1 30:02 0.500 220
GEORGIA 1 29:02 0.286 253
NAVY 1 31:15 0.556 254
VANDERBILT 1 34:08 0.526 131
AUBURN 0 24:13 0.200 129
KENTUCKY 1 38:37 0.500 288
MISSSTATE 1 32:34 0.200 110
TENNESSEE 1 36:18 0.556 231
ARKANSAS 0 29:05 0.667 79
FLORIDA 1 32:04 0.214 215
CITADEL 1 26:44 0.667 256
CLEMSON 1 37:17 0.444 210
NEBRASKA 1 29:11 0.308 121
VANDERBILT 1 31:36 0.250 205
ECU 1 28:42 0.533 131
UAB 1 23:47 0.500 179
MISSOURI 1 32:33 0.500 144
KENTUCKY 1 31:17 0.500 200
GEORGIA 1 33:13 0.417 230
LSU 0 23:03 0.231 34
FLORIDA 0 24:32 0.214 36
TENNESSEE 1 35:22 0.400 147
ARKANSAS 1 31:45 0.538 104
WOFFORD 1 29:11 0.538 171
CLEMSON 1 39:58 0.524 134
MICHIGAN 1 22:01 0.300 85
NCAROLINA 1 29:33 0.357 228
GEORGIA 0 24:58 0.455 226
VANDERBILT 1 37:10 0.647 220
UCF 1 30:49 0.556 225
KENTUCKY 1 29:45 0.556 178
ARKANSAS 1 43:25 0.563 277
TENNESSEE 0 27:38 0.286 218
MISSOURI 1 34:27 0.294 75
MISSSTATE 1 26:14 0.091 160
FLORIDA 1 28:59 0.313 164
CCAROLINA 1 34:31 0.556 352
CLEMSON 1 38:09 0.526 140
WISCONSIN 1 30:34 0.444 117
TAMU 0 22:22 0.222 67
ECU 1 36:19 0.538 175
GEORGIA 1 31:27 0.222 176
VANDERBILT 1 31:02 0.583 212
MISSOURI 0 35:55 0.381 119
KENTUCKY 0 34:20 0.600 282
FURMAN 1 29:37 0.333 267
AUBURN 0 33:31 0.429 119
TENNESSEE 0 30:13 0.462 248
FLORIDA 1 31:30 0.471 95
SALABAMA 1 24:12 0.400 210
CLEMSON 0 31:20 0.400 63
MIAMI 1 28:50 0.467 60
;
PROC PRINT DATA = USCFootballStatsProject;
RUN;
As it currently stands, it is not printing any of the times in the column for TIMEOFPOSSESSION, but it is printing everything else fine. Any ideas as to why it isn't printing that column? I'm using FORMAT TIMEOFPOSSESSION MMSS.;
I plan on doing a logistic regression with the WINORLOSS being the response variable, but I want to make sure that the data is being read in correctly.
Thanks.
Because you told it to read columns 15 to 19 as a number, but the value has a colon in it. You need to either use formatted input.
input ... #15 TIMEOFPOSSESSION STIMER5. ... ;
Or use list mode input with an attached INFORMAT.
informat TIMEOFPOSSESSION stimer5.;
input ... #15 TIMEOFPOSSESSION ... ;

Train our own classifier

Now I am training my own classifier.So for that I am using traincascade.But when I am giving this command 'opencv_traincascade -data facedet -vec vecfile.vec -bg negative.txt -npos 2650 -nneg 581 -nstages 20 -w 20 -h 20' it shows error like this.
PARAMETERS:
cascadeDirName: facedet
vecFileName: vecfile.vec
bgFileName: negative.txt
numPos: 2000
numNeg: 1000
numStages: 20
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 20
sampleHeight: 20
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC
===== TRAINING 0-stage =====
<BEGIN
POS count : consumed 2000 : 2000
NEG count : acceptanceRatio 1000 : 1
Precalculation time: 3
+----+---------+---------+
| N | HR | FA |
+----+---------+---------+
| 1| 1| 1|
+----+---------+---------+
| 2| 1| 1|
+----+---------+---------+
| 3| 1| 1|
+----+---------+---------+
| 4| 1| 1|
+----+---------+---------+
| 5| 1| 1|
+----+---------+---------+
| 6| 0.9955| 0.391|
+----+---------+---------+
END>
Parameters can not be written, because file facedet/params.xml can not be opened.
What is this error.I don't understand.Any one help me to solve this.
Positive samples:
/home/arya/myown/Positive/images18413.jpeg 1 1 1 113 33
/home/arya/myown/Positive/images1392.jpeg 1 113 33 107 133
/home/arya/myown/Positive/face841.jpeg 1 185 93 35 73
/home/arya/myown/Positive/images866.jpeg 2 121 26 64 68 121 26 88 123
/home/arya/myown/Positive/images83.jpeg 1 102 13 107 136
/home/arya/myown/Positive/images355.jpeg 2 92 16 224 25 92 16 117 130
/home/arya/myown/Positive/images888.jpeg 1 108 29 116 71
/home/arya/myown/Positive/images2535.jpeg 1 108 29 111 129
/home/arya/myown/Positive/images18221.jpeg 1 110 34 109 124
/home/arya/myown/Positive/images1127.jpeg 1 110 34 92 104
/home/arya/myown/Positive/images18357.jpeg 1 103 27 142 133
/home/arya/myown/Positive/images889.jpeg 1 86 25 134 124
Negative samples:
./Negative/face150.jpeg
./Negative/face1051.jpeg
./Negative/Pictures174.jpeg
./Negative/Pictures160.jpeg
./Negative/Pictures34.jpeg
./Negative/face130.jpeg
./Negative/face1.jpeg
./Negative/Pictures319.jpeg
./Negative/face1120.jpeg
./Negative/Pictures317.jpeg
./Negative/face1077.jpeg
./Negative/Pictures93.jpeg
./Negative/Pictures145.jpeg
./Negative/face1094.jpeg
./Negative/Pictures7.jpeg
Please be sure that you have already created the folder "facedet" before training your classifier as it does not create it by itself.
It needs this folder to create "params.xml" file in inside it.

c++ Multiples of 5 in sieve of atkin implemenation

I'm solving a problem over at project euler which requires me to find the sum of all primes under 2 million. I tried to implement sieve of atkin and strangely it sets numbers like 65,85 as primes. I looked at the code and algorithm for over a a day but can't find anything wrong. I'm sure it must be something silly but i can't find it. Thanks in advance
i'm using visual studio express 2012.
here's the code:
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <conio.h>
int main(){
long long int limit,n;
std::cout<<"Enter a number...."<<std::endl;
std::cin>>limit;
std::vector<bool> prime;
for(long long int k=0;k<limit;k++){ //sets all entries in the vector 'prime' to false
prime.push_back(false);
}
long long int root_limit= ceil(sqrt(limit));
//sive of atkin implementation
for(long long int x=1;x<=root_limit;x++){
for(long long int y=1;y<=root_limit;y++){
n=(4*x*x)+(y*y);
if(n<=limit && (n%12==1 || n%12==5)){
prime[n]=true;
}
n=(3*x*x)+(y*y);
if(n<=limit && n%12==7){
prime[n]=true;
}
n=(3*x*x)-(y*y);
if(x>y && n<=limit && n%12==11){
prime[n]=true;
}
}
}
//loop to eliminate squares of the primes(making them square free)
for(long long int i=5;i<=root_limit;i++){
if(prime[i]==true){
for(long long int j=i*i;j<limit;j+=(i*i)){
prime[j]=false;
}
}
}
unsigned long long int sum=0;
//print values to a seperate text file
std::ofstream outputfile("data.txt");
outputfile<<"2"<<std::endl;
outputfile<<"3"<<std::endl;
for(long long int l=5;l<limit;l++){
if(prime[l]==true){
sum+=l;
outputfile<<l<<std::endl;;
}
}
outputfile.close();
std::cout<<"The sum is...."<<sum+5<<std::endl;
prime.clear();
return 0;
}
and hers the data.txt i pointed out few errors
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
65<-----
67
71
73
79
83
85<-----
89
91
97
101
103
107
109
113
127
131
137
139
143
145<----
149
151
157
163
167
173
179
181
185<----
191
193
197
199
205
211
221
223
227
229
233
239
241
247
251
257
259
263
265
269
271
277
281
283
293
299
305
307
311
313
317
331
337
347
349
353
359
365
367
373
377
379
383
389
397
401
403
407
409
419
421
427
431
433
439
443
445
449
457
461
463
467
479
481
485
487
491
493
499
503
505
509
511
521
523
533
541
545
547
557
559
563
565
569
571
577
587
593
599
601
607
611
613
617
619
629
631
641
643
647
653
659
661
671
673
677
679
683
685
689
691
697
701
703
709
719
727
733
739
743
745
751
757
761
763
767
769
773
785
787
793
797
803
809
811
821
823
827
829
839
851
853
857
859
863
865
871
877
881
883
887
901
905
907
911
919
923
929
937
941
947
949
953
965
967
971
977
983
985
991
997
1009
1013
1019
1021
1027
1031
1033
1037
1039
1049
1051
1061
1063
1067
1069
1073
1079
1087
1091
1093
1097
1099
1103
1105
1109
1117
1123
1129
1145
1147
1151
1153
1157
1159
1163
1165
1171
1181
1187
1189
1193
1199
1201
1205
1213
1217
1223
1229
1231
1237
1241
1249
1259
1261
1267
1277
1279
1283
1285
1289
1291
1297
1301
1303
1307
1313
1319
1321
1327
1339
1345
1351
1361
1367
1373
1381
1385
1387
1391
1399
1403
1405
1409
1417
1423
1427
1429
1433
1439
1447
1451
1453
1459
1465
1469
1471
1481
1483
1487
1489
1493
1499
1511
1513
1517
1523
1531
1537
1543
1549
1553
1559
1565
1567
1571
1579
1583
1585
1591
1597
1601
1603
1607
1609
1613
1619
1621
1627
1637
1649
1651
1657
1663
1667
1669
1679
1685
1687
1693
1697
1699
1703
1709
1717
1721
1723
1727
1733
1739
1741
1745
1747
1753
1759
1765
1769
1777
1781
1783
1787
1789
1801
1807
1811
1823
1831
1843
1847
1853
1861
1865
1867
1871
1873
1877
1879
1885
1889
1891
1901
1907
1913
1921
1931
1933
1937
1939
1945
1949
1951
1961
1963
1973
1979
1985
1987
1991
1993
1997
1999
You're supposed to flip the entries to the sieve list. In the first nested for loops instead of prime[n]=true; you should have prime[n]=!prime[n];