I'm trying to print the count the even number in a list via a loop, I don't get any results, I tried: assign numbers into a:
a<-31415926535427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788659361533"
Then I split them:
a.c<-strsplit(piestring.c, "")
Then I unlist them:
a.cu<-unlist(piestring.c, recursive = TRUE, use.names = TRUE)
Then I convert them to numerical:
a.cn<-as.numeric(a.cu)
Then I checked if it can get even numbers:
for (stev in piestring.cn) {
if (stev %% 2 == 0) {
print(stev)
}
}
Then I tried to set counter:
counter <- 0
for (stev in a.cn) {
if (sten %% 2 == 0) {
counter <- counter + 1
}
}
I get no results, is there an easier way to count the even number, then print the count of the even number in the first 50 digits?