博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode----204. Count Primes(Java)
阅读量:7294 次
发布时间:2019-06-30

本文共 836 字,大约阅读时间需要 2 分钟。

 

1 package countPrimes204; 2 /* 3  * Description: 4  * Count the number of prime numbers less than a non-negative number, n. 5  */ 6 public class Solution { 7     //Time Limit Exceeded 8     /* 9     public static int countPrimes(int n) {10         int number=0;11         for (int i=0;i
1;19 else if (n%2==0||n%3==0)20 return false;21 else{22 for(int i=2;i<=Math.sqrt(n);i++){23 if(n%i == 0)24 return false;25 }26 }27 return true;28 }29 */30 31 public static int countPrimes(int n) {32 //boolean default is false33 boolean[] IsPrime=new boolean[n];34 int numPrime=0;35 for (int i=2;i

 

转载于:https://www.cnblogs.com/luluqiao/p/5869842.html

你可能感兴趣的文章
Linux的.run文件简单制作
查看>>
ubuntu解压命令(转)
查看>>
C#获取获取北京时间多种方法
查看>>
动态语言的灵活性是把双刃剑 -- 以 Python 语言为例
查看>>
1. 字节序的转换
查看>>
ubuntu14.04LTS下ECLIPSE+JAVA搭建
查看>>
学习RxJS: 导入
查看>>
PowerDesigner大小写转换
查看>>
纯 CSS 利用 label + input 实现选项卡
查看>>
Ubuntu 上安装R
查看>>
How .Net code can call unmanaged code?
查看>>
Archlinux安装配置以及遇到的问题
查看>>
怎么写出好代码——坏味道
查看>>
Java将CST的时间字符串转换成需要的日期格式字符串
查看>>
cisco 查看接口进出流量
查看>>
Dhcp+nfs+tftp+ks 完全无人值守安装linux操作系统
查看>>
TemplateDirectiveModel接口execute方法参数说明
查看>>
Js删除数组重复元素的多种方法
查看>>
att与intel风格对照实例
查看>>
backpack
查看>>