C and Cpp

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingC and Cpp

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 10th, 2007, 10:17 PM
bjuliano bjuliano is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 1 bjuliano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 30 sec
Reputation Power: 0
Need help in the following assignemt

Create an array with all elements initialized to 1 (true). Array elements with prime subscripts will remain 1. All other array elements will eventually be set to zero (false). You will ignore elements 0 and 1 in this exercise.

Starting with array subscript 2, every time an array element is found whose value is 1, loop through the remainder of the array and set to zero every element whose subscript is a multiple of the subscript for the element with value 1. For array subscript 2, all elements beyond 2 in the array that are multiples of 2 will be set to zero (subscripts 4, 6, 8, 10, etc.); for array subscript 3, all elements beyond 3 in the array that are multiples of 3 will be set to zero (subscripts 9, 15, 21, etc. - note that 6 and 12 are not listed as they have already been sieved out when considering all multiples of 2); and so on.


instructions:
Write a program that uses an array of 10,000,000 elements to determine and print the prime numbers between a user-specified lower bound and user-specified upper bound. Your program must also have the following features

Your array could either be an int (or unsigned) array, or a bool array. When using a bool array, the above algorithm is easily modified so that the array is initialized to true and numbers that get sieved out are set to false.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingC and Cpp > Need help in the following assignemt


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap