Fedora Linux Support Community & Resources Center
Prev Previous Post   Next Post Next
  #1  
Old 14th March 2017, 06:13 AM
hiGuys Offline
Registered User
 
Join Date: Jun 2013
Location: USA
Posts: 362
linuxfirefox
Programming Challenge - list prime numbers

Haven't seen one of these programming challenges in a while, so I thought I'd throw one out. Nothing esoteric, just list the prime numbers up to a(n) (arbitrary) point.

Here is one way to do it in python:

Code:
p = [2,3]
x = 5
counter = 1
k=[]
while counter < 10000:
    for i in p:
        y = x%i
        k.append(y)
    if 0 not in k:
        p.append(x)
    k = []
    x += 2
    counter += 1
print(p)
__________________
Mind the gap.
Reply With Quote
 

Tags
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: 21:03 (Sunday, 24-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

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