用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()

相关推荐
AOwhisky1 小时前
Linux(CentOS)系统管理入门笔记(第十五期)——文件系统与存储管理(上篇):设备识别、挂载与文件查找
linux·运维·笔记·centos·文件系统
寒水馨1 小时前
Linux下载、安装 Bun v1.3.14(附安装包bun-linux-x64.zip)
linux·javascript·typescript·node.js·bun·运行时·包管理器
Dear~yxy2 小时前
LVS企业级实战
linux·服务器·lvs
兮动人3 小时前
Linux 安装 Claude Code 实战:Node.js、npm、GLM 配置一次跑通
linux·npm·node.js·cc·claude code
2301_777998344 小时前
Linux线程控制——从线程创建到线程分离(第三部分:线程等待 pthread_join)
linux·运维·服务器·c语言·c++
谜之锋4 小时前
Linux 源码编译安装 net-snmp-5.9.1 并配置使用 SNMPv3
linux·运维·服务器·snmpv3
一直在努力学习的菜鸟4 小时前
阿里云2G2核的服务器可以做什么?
linux·运维
ShineWinsu4 小时前
对于Linux:自定义协议(基于TCP)实现网络计算器的解析
linux·网络·c++·网络协议·tcp/ip·面试·网络计算器
tedcloud1235 小时前
Orca 部署指南:开源 AI 推理服务的 Linux 部署实践
linux·运维·服务器·人工智能·开源·自动化·excel