r/dailyprogrammer • u/rya11111 3 1 • Jun 22 '12
[6/22/2012] Challenge #68 [easy]
Emirp is an interesting concept. The explanation about it is provided in the link i just gave.
Your task is to implement a function which prints out the emirps below a number(input) given by the user.
20
Upvotes
3
u/Purkinje90 Jun 22 '12
Python I know this code is needlessly complex, but here it is:
Program outputs:
3
u/Nohsk Jun 23 '12 edited Jun 23 '12
C
Efficiency could be doubled with a few lines of code, but I'm too lazy.
2
u/onmach Jun 22 '12 edited Jun 22 '12
In haskell:
Edit: slight cleanup.
2
u/Xadoo 0 0 Jun 22 '12
Just an FYI, this is not my regex. I wish I could come up with something so beautiful. Nonetheless, Here is my ruby:
Credit for prime: http://montreal.pm.org/tech/neil_kandalgaonkar.shtml
2
u/devilsassassin Jun 23 '12
In C++, Using the Miller-Rabin Theorem:
2
u/SangriaSunrise Jun 23 '12 edited Jun 23 '12
Probably should have broken it up.
J:
2
u/huck_cussler 0 0 Jun 24 '12
That was tougher than I initially expected. I ended up using 'ascii math' to convert chars to ints. I'm not sure how I feel about that, but it worked.
2
u/scurvebeard 0 0 Jun 26 '12
Very much a programming beginner here. I'm struggling to reverse a given number using Python (not that I know any other language.)
So far I've made a function for determining if a number is prime, a function that turns a given number into a string and reverses it (currently an error-filled mess,) and the main function that should list the emirps below input.
A good challenge, though, and at least I managed to code the isPrime function on my own.
1
u/emcoffey3 0 0 Jun 22 '12
C#
1
u/[deleted] Jun 22 '12
Haskell
1
u/JacqueItch Jun 22 '12
1
u/SwimmingPastaDevil 0 0 Jun 23 '12
1
u/[deleted] Jun 23 '12
Python!
If possible, can I get feedback for this code - it is only the third computer program that I've written and I would like to do a better job designing things in places that they belong - particularly having the right stuff in the right functions, and using variables in a smart way that makes it easy to go back and change things.
1
u/idliketobeapython Jun 23 '12
Python
1
u/EvanHahn Jun 23 '12
Python:
1
u/Imposter24 Jun 24 '12
VB
Any suggestions for streamlining would be appreciated.
skip: Next
End Class
1
u/ixid 0 0 Jun 25 '12 edited Jun 25 '12
In D:
1
u/mrpants888 Jun 26 '12
ruby
1
u/refringence Jul 05 '12
ruby:
1
u/kintu Jul 07 '12
A bit late but
In python:
1
u/ManAmongHippos Aug 03 '12 edited Aug 03 '12
117 characters in Perl:
1
u/loonybean 0 0 Jun 22 '12
Python one-liner (if you import math beforehand):