获取方的免费电话号码清单 [英] Getting a list of square-free numbers

查看:169
本文介绍了获取方的免费电话号码清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要获取的一种方式是自然数(1,... N),我们factorise每一个,看看他们是否有任何重复的首要因素,但是这将需要大量的时间,大的n。那么,有没有更好的办法,从1获得方的免费电话号码,...,N?

one way to get that is for the natural numbers (1,..n) we factorise each and see if they have any repeated prime factors , but that would take a lot of time for large n. So is there any better way to get the square-free numbers from 1,,n ?

推荐答案

您可以使用erastophenes筛的修改后的版本:

You could use erastophenes sieve's modified version:

取布尔数组1..N; preCALC是小于n所有的广场;这是O(开方(N));

Take a bool array 1..n; precalc all squares that are less than n; that's O(sqrt(N));

的foreach广场及其倍数使布尔数组项假...

foreach square and its multiples make the bool array entry false...

这篇关于获取方的免费电话号码清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆