Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Superprime Rib
  2. ==============
  3.  
  4. Butchering Farmer John's cows always yields the best prime rib. You
  5. can tell prime ribs by looking at the digits lovingly stamped
  6. across them, one by one, by FJ and the USDA. Farmer John ensures
  7. that a purchaser of his prime ribs gets really prime ribs because
  8. when sliced from the right, the numbers on the ribs continue to
  9. stay prime right down to the last rib, e.g.:
  10.  
  11. 7 3 3 1
  12.  
  13. The set of ribs denoted by 7331 is prime; the three ribs 733 are
  14. prime; the two ribs 73 are prime, and, of course, the last rib, 7,
  15. is prime. The number 7331 is called a superprime of length 4.
  16.  
  17. Write a program that accepts a number N (1 <= N <= 8) of ribs and
  18. prints all the superprimes of that length.
  19.  
  20. The number 1 (by itself) is not a prime number.
  21.  
  22. PROGRAM NAME: sprime
  23.  
  24. INPUT FORMAT:
  25.  
  26. A single line with the number N.
  27.  
  28. SAMPLE INPUT:
  29.  
  30. 4
  31.  
  32. OUTPUT FORMAT:
  33.  
  34. The superprime ribs of length N, printed in ascending order one per
  35. line.
  36.  
  37. SAMPLE OUTPUT:
  38.  
  39. 2333
  40. 2339
  41. 2393
  42. 2399
  43. 2939
  44. 3119
  45. 3137
  46. 3733
  47. 3739
  48. 3793
  49. 3797
  50. 5939
  51. 7193
  52. 7331
  53. 7333
  54. 7393
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement