Hi, You could also use: x <- "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557"
sapply(strsplit(substring(x,seq(1,nchar(x)-4,5),seq(5,nchar(x),5)),""),function(x) prod(as.numeric(x))) #[1] 882 630 0 648 20 6048 1680 840 540 3888 11664 0 #[13] 1960 0 1890 0 1728 0 16128 480 1920 0 162 6480 #[25] 0 1323 360 3600 0 0 0 12096 1400 864 0 1620 #[37] 0 360 0 2100 A.K. ----- Original Message ----- From: Janesh Devkota <janesh.devk...@gmail.com> To: groep R-help <r-help@r-project.org> Cc: Sent: Thursday, April 18, 2013 4:47 AM Subject: [R] Subsetting a large number into smaller numbers and find the largest product Hello, I have a big number lets say of around hundred digits. I want to subset that big number into consecutive number of 5 digits and find the product of those 5 digits. For example my first 5 digit number would be 73167. I need to check the product of the individual numbers in 73167 and so on. The sample number is as follows: 73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557 I have a problem subsetting the small numbers out of the big number. Any help is highly appreciated. Best Regards, Janesh Devkota [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.