博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Count Primes
阅读量:4073 次
发布时间:2019-05-25

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

Count Primes

Description:

Count the number of prime numbers less than a non-negative number, n

Java代码:

public class Solution {    public int countPrimes(int n) {        boolean[] exist = new boolean[n];	        Arrays.fill(exist, true);	        int count = 0;	        for (int i = 2; i < n; i++) {	            if (exist[i]) {	                count++;	                for (int j = 2; i * j < n; j++) {	                    exist[i*j] = false;	                }	            }	        }	        return count;    }}
 

转载地址:http://vvuni.baihongyu.com/

你可能感兴趣的文章
UNITY3D中涉及的一些数学知识
查看>>
Unity3D粒子系统 合集
查看>>
UNITY在VS中调试
查看>>
Unity StartCoroutine 和 yield return 深入研究
查看>>
Unity-Animator深入系列
查看>>
UNITY3D的变量初始化问题
查看>>
UNITY3D单词学习 speed和velocity的区别
查看>>
Unity3D中的线性插值Lerp()函数解析
查看>>
pitch yaw roll 的区别
查看>>
什么是UV?
查看>>
手机开启HDR后拍照有什么不同?
查看>>
图文详解Unity3D中Material的Tiling和Offset是怎么回事
查看>>
voxel 与 pixel
查看>>
vector3.forward和transform.forward的区别!
查看>>
HOLOLENS的空间管理
查看>>
unity3d 的Quaternion.identity和transform.rotation区别是什么
查看>>
【Unity3d】Ray射线初探-射线的原理及用法
查看>>
迄今最深入、最专业的Hololens评测结果,美国AR大咖艾迪·奥夫曼现身说法
查看>>
全息眼镜HoloLens可快速捕捉真人3D图像
查看>>
copy-paste component
查看>>