palindromic primes



Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

Re: palindromic primes

Postby BillyBoyo » Tue Nov 22, 2011 6:10 am

Who thought C would be a good idea for getting a grasp of mainframes. Cobol code on mainframes would outweigh C by orders of magnitude.

enrico suggested some code for you to include. It starts at the left and right at the same time, comparing until different or it meets in the middle (so a palindrome).

We have been picking holes in the original program. It is not a very good prime number generator implementation. Maybe you get some extra credit for "tarting it up"?

Perhaps you can also turn things around. Generate a list of palindromes up to X, and then find which of those are primes. If you cut the list down to just the odd palindromes, that'll help as well. You'll get the same results. Think about which might be more efficient.

One of the points we are trying to get over to you is that it is not the language implemented in that is so important, it is being able to research/think about the problem to come up with effective solutions, from which you choose the "best fit" depending on exactly what you need.

If you "code" it in pseudo-code, the language is an afterthought, part of the selection of "best fit" even.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: palindromic primes

Postby clrgq » Tue Nov 22, 2011 6:29 am

ya know billy, i didnt really see the connection either but you brought up a good point. i still have not used what enrico put because my main goal for coming here is getting some advice and LEARNING for myself, just needed a kickstart. tarting it up would not be a bad way to go. your advice about putting the problem into perspective is well received! i appreciate your tact and helpfulness!
clrgq
 
Posts: 12
Joined: Tue Oct 25, 2011 4:44 am
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to C, C++