Advertisement
hi everyone I'm in desperate search for some one who would be willing to help me learn how to do some programming. I've already bought a ton of books, but unfortunatly through them I learned that I am the type of person who can't learn through books alone.....you can't really ask them questions and get anwsers.so I was just wondering if enyone out there would be interested in mentoring me, either via internet or if your located within the Sea-Tac area perhaps getting together in person.
Advertisement
Advertisement
-
Re: Mentors
Thu, July 22, 2004 - 7:51 AMyou don't have to learn from just books - you can learn from books and a computer! play around. make little projects for yourself. choose a language to learn first (i'd recommend either Java or Perl, not C++, honestly, for a first language) and just start writing little programs. and im sure people here will be happy to answer questions you have about the code, as well as recommend little projects to work on to get started... -
-
Re: Mentors
Thu, July 22, 2004 - 7:56 AMsounds good,what sort of little programs would you guys suggest to start out with? -
-
Re: Mentors
Thu, July 22, 2004 - 8:06 AMone of the first i give my students (i teach an intro java class) is to print the first 100 prime numbers.
what language have you been using so far? -
-
Re: Mentors
Thu, July 22, 2004 - 4:56 PMI've been trying to teach myself C++ off and on for a few years...thats about it , save a little qbasic back a few years ago. -
-
Unsu...
Re: Mentors
Sat, July 24, 2004 - 11:56 AMSo, how's it going? The primes problem is a classic. Still
interested? Need some help getting started?
-
-
Re: Mentors
Mon, July 26, 2004 - 6:06 PMwell yes of course I'm still interested, and ya I guess I still need help getting started....whats this "Primes problem" exactley? -
-
Re: Mentors
Mon, July 26, 2004 - 6:17 PMPrime numbers are numbers whose only even divisors are
them and 1. For example, 7 is not evenly divisible by anything except 1 and 7. 6, on the other hand, can be evenly divided by 1, 2, 3 and 6.
So what you'd want to think about would be a way to check each number for primeness, ways to find the first 100 such numbers.
Not sure whether to suggest solving first procedurally and then making the solution work in an object-oriented way... -
-
Unsu...
Re: Mentors
Mon, July 26, 2004 - 7:02 PMThere may be another way to think about prime numbers, and non-prime numbers. I'd have to dig out my number theory book to get a complete reference, but the gist of it is that a non-prime number can be divided by one or more prime numbers.
6 can be divided by 3 and 2.
10 can be divided by 5, and 2.
I forget if 0 is considered to be a prime number.
Part of the solution that I came up with was to have a running collection of primes (an array or some other data structure), and then for any number in question, check to see if it is divisible by a number in the collection of prime numbers.
Again what about 0, and since everything is divisible by 1 you have to account for that.
So ... right away you would need to look up how to create and set the values for an array, how loops work, how to do some division, and integer comparison.
-
-
This is the maximum depth. Additional responses will not be threaded.
Re: Mentors
Mon, July 26, 2004 - 8:06 PMThere are several ways. If there's a general method
IsPrime( long ltestNum ), you could always swap in an
IsPrimeSmarter( long lTestNum ) which is much more efficient.
But you have to walk before you can run...
Here's a description of the Sieve of Erstothanes.
Also, I don't think this QUITE covers an approach I've been thinking of:
- see if 2 divides into it; if so, no poiont in checking n/2
- see if 3 divides into it; if so, no poiont in checking n/3
- see if 5 divides into it; if so, no poiont in checking n/5
And so on with increasingly big primes...
We have some bigger math heads than me on the list, they might suggest an optimal approach. But getting off the ground in the first place is more important than optimizing...
-
-
-
-
-
-
Re: Mentors
Sun, August 22, 2004 - 11:23 AMIf you know some math, this problem is trivial. To check if any number <= 100 is a prime, you only have to try dividing it by primes < 10 (10 being the square root of 100). So you only have to test the divisibility by 2, 3, 5, and 7.
The sieve of Erastothenes can be used to speed up the process. In the series 1, 2, 3, ... 100, mark as non-prime number:
one (not prime by definition),
every other number(i.e. divisible by 2) except 2,
every third number (i.e. divisible by 3) except 3,
every fifth number (i.e. divisible by 5) except 5, and
every seventh number (i.e. divisible by 7) except 7.
The ones that are left are prime.
Being able to understand such algorithms is a prerequisite to programming. So it's a good idea to also refresh your math.
-
-
-
-
Unsu...
Re: Mentors
Wed, July 28, 2004 - 5:11 AMDouglas Hoffstadter has a really cool article (3 actually) about Recursion in the book Metmagical Themas if you can find it.
It's three short articles and he uses LISP. He assumes no prior knowledge of LISP (it's a pretty easy language to get the basics down in, the first article is dedicated to getting you started in LISP, the second and third are about recursion.).
There is nothing like learning programming concepts from Douglas Hoffstadter.