用bc脚本求解大质数

日期:2013-01-21

下面是求解大质数bc脚本,程序是从网上查找的C语言程序,然后做的修改。

/*this is a bc scripts, it can find some prime numbers.

the numbers between n to n+m, they are maybe some big numbers.

You can change k and m, k can affect n.

This program more part is copied from web

You can save it as primes.bc,

then use this command in bash: bc primes.bc

2013-1-20

*/

k=3*10^12 +1 #set k value

m=1000 #set m value

n=6 +k-k%6 #n is 6 * i

s=sqrt(n+m)+ 6 #it is max value to be divided a numbers

define main()

{

end=n+m

for(index=n;index+5<=end;index+=6) #Just test 6*n+1,6*n+5

{

num=index+1

if(judge(num)==1)

num

num=index+5

if(judge(num)==1)

num

}

}

define judge(judge_num)

{

if((judge_num%5)==0)

return (0);

for(indexs=6;indexs+5<=s;indexs+=6) #Just test 6*n+1,6*n+5

{

if(judge_num%(indexs+1)==0)

return (0);

if(judge_num%(indexs+5)==0)

return (0);

}

return (1);

}

main()

相关推荐
雯宝10 小时前
mnt_init 函数
linux
律宏阔16 小时前
WSL Docker 端口明明空闲,但就是绑不上端口
linux·windows
律宏阔16 小时前
WSL 突然断网,无法 ping 内网或外网
linux·windows
穷人小水滴16 小时前
用容器编译 VirtualBox 虚拟机软件 (ArchLinux, podman)
linux·容器·virtualbox
乱码三千17 小时前
如何优雅地直连无公网 IP 的远程 GPU 服务器
linux·人工智能·程序员
yunwei3717 小时前
使用 eBPF 跟踪 Nginx 请求
linux·后端·性能优化
yunwei3717 小时前
使用 eBPF 跟踪 MySQL 查询
linux·后端·性能优化
yunwei3717 小时前
eBPF 示例教程:使用 XDP 捕获 TCP 信息
linux·后端·性能优化
GeW17 小时前
制造业高端化,为什么必须重估Linux和数据库?
linux
GeW17 小时前
工业场景中的Linux与数据库选型:高端化转型的技术底座
linux