Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Java Primarlity finding a remainder

1. ## Java Primarlity finding a remainder

hey people. I need some tips on how to write the algorithm for this problem. If someone could please explain the idea and give me a framework for how to write the data algorithm for this then that would be great.

The following question is a twist on the age-old primality problem. Primality is defined on integers, and an integer
is prime if it is,
a. More than 1.
b. Divisible only by 1 and itself
The first few prime numbers are: 2, 3, 5, 7, 11, 13, ...
You are required to complete the method isAlmostPrime that when passed a positive integer, returns true if it
has exactly three positive divisors, and false otherwise. That is, the method returns true, if besides 1 and itself,
the integer has exactly one other positive divisor. For example, the method should return true for parameter 4,
since it has exactly three divisors: 1, 2, and 4. The method should return false for parameter 6, since it has four
divisors: 1, 2, 3, and 6.
The method should return false for any value less than 2 passed to it.

2. ## Re: Java Primarlity finding a remainder

Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.