计算2..n的素数
2024-09-25 16:15:33
def check(2) , do: true
def check(n) when n >2 do
b = for x <- (Enum.into 2..n-1,[]),do: x
if chec(n,b,[]) == [] do
true
end
end def chec(n,[m|r],ss) when rem(n,m) ==0, do: chec(n,r,[m|ss])
def chec(n,[m|r],ss), do: chec(n,r,ss)
def chec(n,[],ss), do: ss def span2(n) when n > 2 do
for x <- (Enum.into 2..n, []), check(x) == true , do: x
end
def span2(n), do: "n must > 2"
IO.inspect(span2(40)) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
最新文章
- ubuntu 下应用 Python 和 SL4A 的 Android 应用程序搭建您自己的android研发环境
- 基于网格的波动方程模拟(Wave equation on mesh)附源码
- C#中用schema验证xml的合法性
- mq_unlink
- poj3083
- 使用HTML5 WebDataBase设计离线数据库
- mac在 aliyun linux ecs实例上安装 jdk tomcat mysql
- 【转】windows消息16进制对应表
- 写一个Windows上的守护进程(5)文件系统重定向
- XSD (xml Schema Definition)
- 【剑指offer】员工年龄排序
- SLAM入门之视觉里程计(2):相机模型(内参数,外参数)
- Unity3D实现多语言切换
- Zookeeper的概述、安装部署及选举机制
- D5 F
- .NET Core 用 VS Code新建各种类型的项目
- 大数据学习路线:Zookeeper集群管理与选举
- CRM 更新解决方案之注意事项
- UI自动化环境准备
- Leetcode: Binary Tree Level Order Transversal II
热门文章
- [翻译]Component Registration in Script System 在脚本系统中注册组件
- 解决json结合struts2时,Class org.apache.struts2.json.JSONWriter can not access a member of * 的问题
- jenkins任务构建失败重试插件Naginator Plugin
- ashx、aspx、ASP.NET MVC
- Git命令行学习积累
- html中常用的标签元素
- UWP开发砸手机系列(一)—— Accessibility
- Vue前端数据采集 埋点 追踪用户系列行为
- Luogu1438 无聊的数列(单点查询)&;&;加强版(区间查询)
- ADV拍卖