php 实现欧拉函数Euler
来源:互联网 发布:unity3d 官方demo 编辑:程序博客网 时间:2024/06/06 05:40
欧拉函数ph(n)的意思是所有小于n且与n互质的个数。
比如说ph(10) = 4{1,3,7,9与10互质}
比如说ph(10) = 4{1,3,7,9与10互质}
代码如下:
1 function Euler($x) 2 { 3 $res = $x; 4 $now = 2; 5 while ($x > 1) { 6 if ($x % $now == 0) { 7 $res /= $now; 8 $res *= ($now - 1); 9 while ($x % $now == 0) {10 $x /= $now;11 }12 }13 $now++;14 }15 return $res;16 }17 18 $res = Euler(10);19 20 var_dump($res);
function Euler($x)
{
$res = $x;
$now = 2;
while ($x > 1) {
if ($x % $now == 0) {
$res /= $now;
$res *= ($now - 1);
while ($x % $now == 0) {
$x /= $now;
}
}
$now++;
}
return $res;
}
$res = Euler(10);
var_dump($res);
done!
阅读全文
0 0
- php 实现欧拉函数Euler
- 欧拉函数(Euler)
- 欧拉函数euler
- 欧拉函数euler
- 欧拉函数 (Euler Function)
- 【BJOI】【欧拉函数】Euler
- The Euler function(欧拉函数)
- hdu2824 The Euler function (欧拉函数)
- hdu2824 The Euler function 欧拉函数
- hdu2824 The Euler function 欧拉函数
- 2824 The Euler function【欧拉函数】
- The Euler function【欧拉函数】
- UVa1342That Nice Euler Circuit(欧拉函数)
- euler欧拉函数学习入门
- 欧拉函数(Euler' totient function )
- Euler 欧拉
- Euler(欧拉通路)
- hdu2824 The Euler function 欧拉函数模板题
- 完美解决IE9浏览器出现的对象未定义问题
- php常量PHP_EOL
- Makefile学习(一)
- 数独求解程序 php版
- php取两个整数的最大公约数算法大全
- php 实现欧拉函数Euler
- Python自动化脚本【2】从sql文件中随机抽取条目
- 好玩的一句话签名
- 三阶魔方还原公式
- Gentoo安装Virtualbox
- HTML5 localStorage使用教程
- 利用Navicat for mysql 导出和导入数据库
- zuul网关的设计思路的思考
- 【剑指offer】【二维数组中的查找】【有序二维数组整数查找】【判断二维数组是否为空方法】