<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Fermat Last Theorem</title>
<script>
(function(){
//f(x)=x^3-x
function f(x){
return Math.pow(x,3)-x;
};
//P_maxまでの素数を求めてpに入れる
const P_MAX=100;
var p=[];
prime();
const P=p.length
var N_p=[];//素数pごとの解の個数
//p[i]はi番目の素数
for(var i=0;i<P;i++){
var count = 0;
for(var j=0;j<p[i];j++){
var yy=f(j)%p[i]//右辺 mod p
//√yyだけでなく√(yy+kp)についても解になるか考える
for(var k=0;Math.sqrt(yy+k*p[i])<p[i];k++){
var y=Math.sqrt(yy+k*p[i]);
if(y%1==0){
count++;//yが整数なら解として数える
};
};
};
N_p[i]=count;
};
console.log("p :"+p);
console.log("N_p:"+N_p);
//素数を求める関数
function prime(){
p=[2,3]
for(var i=5;i<P_MAX;i=i+2){
var flag=0;
for(var j=3;j<i/2;j=j+2){
if(i%j==0){
flag=1;
break;
};
};
if(flag==0){
p.push(i)
};
};
}
})();
</script>
</head>
<body>
</body>
</html>
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme