The simple implementation method for php to calculate the circumference rate is original. fontcolor_PHP tutorial

Source: Internet
Author: User
Php's simple method for calculating the circumference ratio is original, fontcolor. The simple implementation method for php to calculate the circumference rate is original. fontcolor this article describes the simple implementation method for php to calculate the circumference rate. For your reference, I will share with you the following details: the simple implementation method of php to calculate the circumference is original, fontcolor

This article describes the simple implementation of php to calculate the circumference rate. We will share this with you for your reference. The details are as follows:

In the previous article "C language for circumference rate", we provided a simple calculation method for circumference rate. here, we use the previous code to provide the calculation method for php to calculate the circumference rate. The code is as follows:

<? Php $ t = 1; $ pi = 0; $ n = 1.0; $ s = 1; while (abs ($ t)> 1e-6) {$ pi = $ pi + $ t; $ n = $ n + 2; $ s =-$ s; $ t = $ s/$ n ;} $ pi = $ pi * 4; printf ("pi = % 10.6f", $ pi);?>

Calculation result:

Pi = 1, 3.141591

Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming and increase the readability of the code:

Php code online formatting and beautification tools:

Http://tools.jb51.net/code/phpformat

In addition, because php belongs to the C language style, the following tool can also format php code:

C language style/HTML/CSS/json code formatting and beautification tools:
Http://tools.jb51.net/code/ccode_html_css_json

Related Article

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.