Calculate the number of occurrences of 93 in 1 to 100000

Source: Internet
Author: User


A classmate on the group asked to calculate 1 to 100000 of the number of occurrences of 93, and then I wrote the script.


Cat count.sh #!/bin/bashsum=0for num in {1..100000}doecho $num | grep 93[$?-eq 0] && ((sum=sum+1)) Doneecho "sum= $sum"


Then one of the students gave me the answer, and the second killed me 10,000 miles.

Seq 1 100000 | grep |wc-l


I want to quiet/(ㄒoㄒ)/~~ let me quietly 650) this.width=650; src= "/e/u261/themes/default/images/spacer.gif" style= "Background:url ("/e/ U261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/> 650) this.width=650, "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images /localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

This article is from the "Do not forget Beginner's mind" blog, please be sure to keep this source http://winterysea.blog.51cto.com/9677346/1663578

Calculate the number of occurrences of 93 in 1 to 100000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.