Open sx349 opened 4 years ago
注意到第三个包含于第一个
3b^2-b-4c^2+2c=0
解出来枚举判断判别式是否是整数即可
# 注意到 Tn 包含 Hn
'''
for i in range(1,100000000):
fuck=(1+(48*i*i-24*i+1)**0.5)/6
# print(fuck)
if(fuck==int(fuck)):
print(fuck)
'''
print(31977*(31977*3-1)//2)
#include <stdio.h>
_Bool isPen(long long int n);
float qsqrt(float n);
int main(){
int i=1;
long long int num=1;
while(1){
num+=(4*i+1);
if(num>40755&&isPen(num)){
printf("%lld", num);
break;
}
++i;
}
return 0;
}
_Bool isPen(long long int n){
long long int x=(long long int)qsqrt((float)(n*24+1));
if(x*x==n*24+1&&((1+x)%6==0)){
return 1;
}
return 0;
}
float qsqrt(float n){
float nhalf=0.5f*n;
int i=*(int *)&n;
i=0x5f375a86-(i>>1);
n=*(float *)&i;
n=n*(1.5f-nhalf*n*n);
n=n*(1.5f-nhalf*n*n);
return 1/n;
}
Select[Range@100000, IntegerQ[1/6 + 1/6 Sqrt[1 - 24 # + 48 #^2]] &]
n (2 n - 1) /. n -> %[[3]]
https://pe-cn.github.io/45/
Problem 45 Triangular, pentagonal, and hexagonal Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15,