| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
|
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
7 comments so far (post your own) View All Comments Latest 10 Comments:can any one help me to give a program in micro controller for checking whether a given number is prime or not ,,,,,,,,,,,,,urgent
Posted by jerin on Friday, 10.3.08 @ 20:58pm | #80877
I have this Prime Checking Java coding problem:
A prime number ‘p’ is a positive integer (p>1) that can only be divided evenly by:
a) ‘p’ Itself (so the result of the division is: p/p = 1)
b) 1 (so the result of the division is p/1 = p)
The first few prime numbers are:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31
Write a Class PrimeChecker that has checkPrime() method as follows:
public class PrimeChecker {
public static boolean checkPrime(int anyNumber){
// write your logic here
}
public static void main(String[] args) {
boolean found = false;
for (int p=-5; p<35;p++){
found = checkPrime(p);
if (found){
System.out.print(p + "\t");
}
}
}
}
Obviously, the method checkPrime will take in any integer and return true of false depending on whether integer is Prime or not.
As a tester for your code, the main method is sending a series of integers to the checkPrime method.
Here is the expected output:
2 3 5 7 11 13 17 19 23 29 31
Thanks.
Posted by Cris on Monday, 03.10.08 @ 04:58am | #52148
thanks for ur help
Posted by paddu on Thursday, 09.20.07 @ 19:04pm | #28204
This is a very simple implementation of a prime number check. I feel checking every single divisor of a number to verify its primality is sort of 'brute force' is there a more elegant way to do this?
Posted by Saleem on Thursday, 05.10.07 @ 15:08pm | #15568
how to develop java progrmas logic
Posted by saikrishna on Sunday, 03.25.07 @ 16:35pm | #12661
i found very interesting and easy to understood your explanations and i think you're doing a terrific job.
as all of beginners, i need a little help from u:
what if i have more numbers i have to find the prime one, how can write the code?
thank u for your time and best regards
PDE
ps- hope u have time for my question
Posted by PDE on Thursday, 01.11.07 @ 05:45am | #3169
wow! this is really cool. an easy program that is. can you tell me what the % do? does this really compute all prime numbers including above million? becuase I tried to input more than a million and it always come out to be "not prime," I'm just not sure if it's really accurate. is it?
do you have a program for a simple calculator that computes 3 operations, as for example 89+34*6 - in this case, it follows the math rule which executes the multiplication first then addition?
well, i just need a little help in starting my project. and i hope you would be able to read this and consider my request.
thanx.
Posted by Markhooz on Monday, 12.11.06 @ 08:19am | #745