• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Prime Number

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea how to write a program to print all the prime numbers within 10000 which has three “7” digits. Examples: 1777

Class java() {

public static void main(String arg[]) {

......

Please help!
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you trying to implement it in Java? From the few lines of code you have provided- I assume you are not familiar with Java. If its a homework question please DoYourOwnHomework , and you cannot expect anyone here to just give you the program for the same.

The steps which I can think of-
- Find the prime numbers within 10000- You can get the algorithm for this from a lot of places or you can write one yourself.
- Now to find out if there are three 7's you can either- Convert the number into a string and find if it has three 7's or you can find individual digits in the number and see if it has three 7's. Again for the second method there's a standard approach and you can find this algorithm in programs that deal with reversing a number.

So once you have some code and not able to proceed further do let us know and we will help you out.
 
lowercase baba
Posts: 13074
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or you could generate every possible number with three sevens, then test to see if each is prime. I think there are only 40.
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic