Composite Number

Author

Eric W. Weisstein
August 25, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PrimeNumbers/CompositeNumber.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/CompositeNumber.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

NextComposite[n_Integer]:=FixedPoint[n+PrimePi[#]+1&,n]
Composites[n_]:=Complement[Range[n],Prime[Range[PrimePi[n]]]]
CompositeQ[n_]:=!PrimeQ[n]
SetAttributes[CompositeQ,Listable]

Composites

Composites[10]

CompositeQ[Range[10]]

Next Composite

NextComposite[10^8]//Timing

NextComposite/@Range[10]