[Scilab-users] ?= ?==?utf-8?q? e

arctica1963 arctica1963 at gmail.com
Wed Feb 12 16:40:45 CET 2020


PI250KDP.TXT <http://mailinglists.scilab.org/file/t495709/PI250KDP.TXT>  
PI500KDP.TXT <http://mailinglists.scilab.org/file/t495709/PI500KDP.TXT>  

clear
// path to the txt file
path = 'PI250KDP.txt'
// read the file as string
piAsString = csvRead(path, [],[],'string')
// split the string at '' (use no token) 
[piAsString] = strsplit(piAsString,'');
// convert string to double
piDigits = strtod(piAsString);
// search: how often appears a certain value in a specific range within the
digits
searchRange = 10000;
searchVal = 1;
// adapt the range, to search only places behind the decimal sign
[locations] = find(piDigits(1:searchRange+1) == searchVal); // small tweak
here
printf("The number %d appears %d times in the first %d digits of
Pi\n",searchVal,length(locations),searchRange) ;
printf("The number %d appears at following locations: \n", searchVal);
disp(locations');

The 250K file works; the 500k file fails



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html



More information about the users mailing list