Write a program to check whether a number is prime in java

To determine whether a given number is prime, we need to check if it has factors others than one and itself. If we are able to find atleast one other factor, then we can conclude that the number is not prime. To check if a number is a factor of the given number hereafter referred to as nwe obtain the remainder on dividing n by the number. If the remainder is zero, then the number is a factor.

Write a program to check whether a number is prime in java

August 09, I have divided them into 10 different topic areas that I think the project may use the most. Keep in mind that a few of these projects could have been classified in more than one topic. So I hope you enjoy and here they are! Keep a limit to how far the program will go.

Also figure out how long it will take the user to pay back the loan. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. Make it a scientific calculator for added complexity. The user enters the type of unit being entered, the type of unit they want to convert to and then the value.

The program will then make the conversion. This program may require finding coordinates of the cities like latitude and longitude. It then returns the tax plus the total cost with tax.

To form the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed Ex.: Read Wikipedia for more information on rules. For added complexity have it report a sum of each vowel found.

Terms and Definitions

For added complexity read these strings in from a text file and generate a summary. Add syntax highlighting and other features. You can have the program also add popup reminders.

The user can set how often the stocks are checked and the program can show green up and red down arrows to show which direction the stock value has moved. It can allow comments or not and timestamps all entries.

Could also be made into a shout box. Then send them to a friend. Great for making online documentation of standard text documentation.

How does this prime number test in Java work? - Stack Overflow

Great for software developers looking to make shareware that can be activated. It will then run the regular expression against the source text and return any matches or flag errors in the regular expression. There are various clocks across the world.

Do a search for a list of them. For added complexity, create your own protocol to facilitate this chatting. On any successful connections mark the port as open.

It may require the use of your own private network and a second computer to test with. If it is down, it will notify you by email or by posting a notice on screen.

Added complexity would be to try and implement streaming video, create a server-side language, or serve up other stream types.

Create a product class which has a price, id, and quantity on hand. Then create an inventory class which keeps track of various products and can sum up the inventory value.

Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be available and can be scheduled. Assign their scores on tests and assignments to the students and figure out their average and grade for the class.

For added complexity put the students on a bell curve. Manage credits and debits from these accounts through an ATM style program.

Manage a collection of various books and allow the user to check out books or return books. For added complexity generate a report of those books overdue and any fees. Also allow users to put books on reserve.

Have a doctor that can handle multiple patients and setup a scheduling program where a doctor can only handle 16 patients during an 8 hr work day. Put them in a program which displays them in a gallery style format for viewing.Strong Numbers are the numbers whose sum of factorial of digits is equal to the original number.

Given a number, check if it is a Strong Number or not. 1) Initialize sum of factorials as 0.

write a program to check whether a number is prime in java

2) For every digit d, do following a) Add d! to sum of factorials. 3) If sum factorials is same as given. If the sum of the factorial of each digit is equal to the given number then it is called Strong Number.

Simplest programming tutorials for beginners

In this article, we will show you, How to write a Java Program for Strong Number using While Loop, For Loop, and Functions. We will also show you, How to print Strong Numbers between 1 to n.

Prime Number program in C. Prime number in C: Prime number is a number that is greater than 1 and divided by 1 or itself. In other words, prime numbers can't be divided by other numbers than itself or 1.

For example 2, 3, 5, 7, 11, 13, 17, 19, are the prime numbers. Program: Write a program to check the given number is a prime number or not? Description: A prime number (or a prime) is a natural number greater than 1 that has no .

sleep(): It is a static method on Thread class. It makes the current thread into the "Not Runnable" state for specified amount of time.

write a program to check whether a number is prime in java

During this time, the thread keeps the lock (monitors) it has acquired. In this post, we will write two java programs, first java programs checks whether the specified number is positive or negative. The second program takes the input number (entered by user) and checks whether it is positive or negative and displays the result.

How to determine a prime number in Java – srmvision.com