Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
2 answers
100 views

Primality Test Refactoring

I devised a new primality test isPrimeNumber() below which determines if 1000000007 is prime. It works fine but the code looks unprofessional in my opinion. Is there any way to refactor it to make it ...
vengy's user avatar
  • 203
1 vote
2 answers
3k views

Recursion function for prime number check

I have this code: ...
MM1's user avatar
  • 129
12 votes
4 answers
1k views

Deletable primes

I came across this problem and I was wondering if you could help me to improve my solution. Problem: Count the number of ways you can reduce a deletable prime to a one digit number. A "...
andreeas26's user avatar
3 votes
3 answers
1k views

Prime factoring function using recursion

As a programming exercise, I decided to make a prime factoring function using recursion: ...
Jason Heddle's user avatar
1 vote
1 answer
316 views

Simple Factor Class

I have a class which lazily factors numbers. It provides the user with these methods: getFactors returns a ...
Jonathan Mee's user avatar
3 votes
1 answer
224 views

The Miller-Rabin Primality Test in Clojure

I am new to clojure and I wanted to test out my skills by taking an existing implementation written in Python and writing it in Clojure. Concerns My main concerns are where I use ...
Jeel Shah's user avatar
  • 177
2 votes
1 answer
5k views

A prime number sieve using recursion

Out of curiosity, I built a recursive Sieve of Eratosthenes in Python and I was wondering how it could be improved for efficiency and how it can improved to be aligned with python best practices. ...
Jeel Shah's user avatar
  • 177
4 votes
4 answers
1k views

Miller-Rabin Recursive Primality Test

I'm working on a primality test and have written a recursive function that returns the value of the function \$b^{q-1} \bmod q\$ where \$3<= q <= 32000\$ Is there any way to speed up my ...
TheJackal's user avatar
  • 269
2 votes
2 answers
817 views

Replacing an F# loop over a mutable variable by an immutable approach

Consider: let mutable m' = m while m' % i = 0L do m' <- m' / i I've refactored it into: ...
devoured elysium's user avatar
6 votes
1 answer
554 views

Is a Recursive-Iterative Method Better than a Purely Iterative Method to find out if a number is prime?

I made this program in C that tests if a number is prime. I'm as yet unfamiliar with Algorithm complexity and all that Big O stuff, so I'm unsure if my approach, which is a combination of iteration ...
Vincent's user avatar
  • 163