Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!

# S Connor

Ranch Hand
since Aug 15, 2013
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by S Connor

The book is called Java how to program seventh edition by Dietel and Dietel chapter 6 ex 25
1 year ago
That's what I thought. However the programming book I am studying from which the question originates has not yet covered data structures of any kind. I thought there might be a clever way to do this that I had missed.
1 year ago

What I am still not clear on is how I can 'cross off' numbers. I don't have any way to record which values of n are prime or not.
1 year ago
If I have understood this correctly, the question is not asking 'how many valyes of n up to 10,000 do you have to test' since you have to test pretty much all values of n.

Instead it is asking, when testing values of n, what size number to you need to test up to to know you have found all the factors and thus whether n is a prime number.  Is that correct?

By the way I am not a college student,  just have taken up coding as a hobby.  I'm really happy to have your help with this!
1 year ago
Thank you for the suggestion, however at this stage in the exercise book there has not yet been any mention of arrays or bit set.   I'm wondering if there is a solution using the basics?
1 year ago
It would seem that I need a way to mark the numbers in the sequence that are not prime. Do you have any suggestions of how I might do this please? I saw that someone mentioned lists abobe,  however this has not been covered in my exercise book so far and nor have atrays nor writing to console as someone earlier suggested.
1 year ago
Here is my solution to the first part of the problem.

I am confused by this question.  I have quoted the exact question in my post above.  'How many numbers up to 10,000 do you have to test to ensure that you have found all the primes?'
Well it seems to me that you have to test all the numbers up to 9973 to ensure that you have found them all.  But how would you translate this into code?
1 year ago
Thanks for the advice. I am following an exercise book which has not so far mentioned sets or recording to console.  Now that I think about it, an array to store the numbers would be unwieldy at best.  I'm wondering if there is an elegant solution that does not require recording of which numbers are prime?
1 year ago
I'm just thinking there needs to be a way to record which numbers are not prime.
1 year ago
Is it possible to use the sieve without needing an array?
1 year ago
Hello,

I am stuck on this beginner question:

a)Write a method that determines whether a number is prime. (I can do this part.)
b)Use this method in an application that determines and displays all the prime numbers less than 10,000.  How many numbers up to 10,000 do you have to test to ensure that you have found all the primes?

I can't see how you would know you had found all the primes without testing each and every number.

Any tips?
Thanks
1 year ago
The wording of the question is:
"Modify the application in Fig 5.6 to use only integers to calculate the compound interest."
3 years ago
hi, I used an int to represent the rate of interest, which is 5%
to find 105% of a given value I used an int 105.
To find the following years interest I thought would be 105*105 and the following year 105*105*105 etc. This soon became too long for an int to hold.
3 years ago
Hi,

I am attempting to find a solution to an exercise in Deitel and Deitel How to Program Java. The exercise says you should be able to modify the code below to use only integers.

I am stuck since using an int for the interest calculations soons becomes too large to be of use. Do you have any suggestions?

3 years ago
This worked a treat thanks.
4 years ago