Fedora Linux Support Community & Resources Center
Prev Previous Post   Next Post Next
Old 18th March 2017, 08:20 PM
RupertPupkin's Avatar
RupertPupkin Offline
Registered User
Join Date: Nov 2006
Location: Detroit
Posts: 6,640
Re: Programming Challenge - list prime numbers

Here's an example in Julia. It only lists all primes up to the number N, so it's comparable to the examples other people here have given. It requires Julia 0.5.0, which is in the F25 repos (dnf install julia).

Save this as getPrimes.jl:
import Primes
println(primes(2, parse(Int64, ARGS[1])))
Sample output:
$ julia getPrimes.jl 100
Takes under 2 seconds to get all primes up to 1 million, and under 40 seconds for up to 1 billion:
$ time julia getPrimes.jl 1000000 > primes.log

real    0m1.634s
user    0m1.471s
sys     0m0.250s

$ time julia getPrimes.jl 1000000000 > primes.log

real    0m38.366s
user    0m30.577s
sys     0m2.235s
OS: Fedora 26 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 7GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote

challenge, list, numbers, prime, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Challenge: Create a list of X random numbers between Y and Z sea Programming & Packaging 6 14th December 2015 06:28 AM
A programming challenge. lsatenstein Programming & Packaging 3 4th January 2015 04:04 AM
Programming Challenge: Comparing Numbers in a String Flounder Programming & Packaging 23 10th January 2014 03:53 PM
[BASH]: Prime Numbers sea Guides & Solutions (Not For Questions) 14 21st November 2012 10:18 AM
Program to find prime numbers renkinjutsu Programming & Packaging 9 4th September 2011 07:40 AM

Current GMT-time: 19:44 (Tuesday, 26-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat