This week's book giveaway is in the Cloud/Virtualizaton forum.We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# generating numbers from 1 to 100 to store in an array

Muzafar Ali
Ranch Hand
Posts: 34
write a program to generate 100 int numbers, strore in array, then display all those numbers which are prime numbers?

but how i can print prime numbers from 1 to 100 but this whole question confused me?

Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Muzafar Ali wrote:write a program to generate 100 int numbers, strore in array, then display all those numbers which are prime numbers?

but how i can print prime numbers from 1 to 100 but this whole question confused me?

Think of it as three steps.
1) Can you write a loop that iterates 100 times?
2) Can you create an array of those numbers?

So far, this should be easy.

Now the prime number part. How do you know if a number is prime? Try talking it out by writing here and then once you have the idea you can write it as code.

Muzafar Ali
Ranch Hand
Posts: 34
A prime number is a number which is self devisble, mean a number that cannot be devide with other numbers!
am i correct sir?

Henry Wong
author
Marshal
Posts: 21127
78
Muzafar Ali wrote:A prime number is a number which is self devisble, mean a number that cannot be devide with other numbers! am i correct sir?

Correct. Now how do you propose testing to see if a number is prime?

Henry

Muzafar Ali
Ranch Hand
Posts: 34
Thanks,

In program i can but when combining whole the program i can't !

David Newton
Author
Rancher
Posts: 12617
Where are you having problems?

fred rosenberger
lowercase baba
Bartender
Posts: 12127
30
how would you test a number like 81 to see if it was prime? Forget about java, write it out in words. How would you start?

David Newton
Author
Rancher
Posts: 12617
http://www.wolframalpha.com/input/?i=PrimeQ[81]

So we use HTTPClient to create a request...