Home > php教程 > PHP源码 > body text

Calculate 1+12+123+1234+12345+...+1234567

WBOY
Release: 2016-08-10 08:49:22
Original
3411 people have browsed it
跳至 [1] [全屏预览]
<?
	/*
		作者: shyhero
		邮箱: shyhero@outlook.com
		Q  Q: 1757424878
	*/
	//  计算1+12+123+1234+12345+...+1234567
	
	
	for($i=1;$i<=7;$i++){
		$str .= $i;
	}
	$str = (int)$str;
	var_dump($str);
	
	$sum = 0;
	
	for($i=$str;$i>=1;$i=(int)($i/10)){
		$sum += $i;
	}
	echo $sum;
?>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!