Thursday, October 5, 2017

Prime numbers generator - 6 - 171005Th

  Prime numbers generator - 6 [1/2]  
.
(Finds all prime numbers between 2 and 32000000002 - c#)
Version: 171005Th
.
Once upon a time a few decades ago I was frequent visitor of "Liaquat National Memorial Library - Karachi" for reading books. I do not actually remember now how and when I went there for the first time. But I do remember that I continued going there for a few years. Although books on computer programming were my main interest but I enjoyed reading books on different subjects and reading different news papers as well. Books on "Lisp" and "Prolog" I studied there for the first time, but my main interest was books on "C" programming language and there were a lot of good quality books available there on C.
.
Environment of "Liaquat National Memorial Library" was very good: calm and peaceful. After a few visits I learned that if I do not come early then surely I will not get chair in the huge reading hall of the library. It was great to know that "Liaquat National Memorial Library" was in so huge demand. Therefore, after knowing that, whenever I went there, I went early.
.
Because "Liaquat National Memorial Library" is located beside PTV Karachi therefore during coming and going I also had some glimpses of TV stars of that time e.g. "Subhani ba Yunus" etc. As far as I do remember I also saw famous movie star of Pakistan "Mohammad Ali" one afternoon standing with someone near entrance steps of library building. I think he was minister at that time. Then time was around afternoon and I was mentally very busy and/or occupied in getting photostat of some chapters of computer book on Unix. Otherwise at least I would have requested for his autograph. He was tall with pinkish white in color and had a pleasant smile on his face. I think I missed the opportunity.
.
Let’s come back to the topic. On one visit to "Liaquat National Memorial Library" I requested for the current book of "Guinness book of world records". And in that book, for the first time I came to know about competition for finding prime number with larger number of digits than number of digits in any already known prime number. I knew how to find weather a number is Prime or not so automatically an idea visited my mind to find some prime numbers on computer myself.
.
Since then I am trying different softwares available to me on different times for making applications for finding as many prime numbers as possible. The list of softwares I used so far is as follows:
.
  1. Turbo C version 2 ON Pentium 2 and Pentium 3
  2. Html and JScript ON Pentium 4
  3. GCC ON Pentium 3 and i5
  4. C# 6 ON Pentium 3
  5. C# 2008 ON Pentium 4
  6. C# 2010 ON i5
.
On different times in different softwares I tried different methods for finding prime numbers like “long hand division method” and different variations of “Sieve method”. Also I kept researching on the internet and there I found pages on some sites displaying first few prime numbers for example first million prime numbers etc. I said Ok . . . I am also finding prime numbers, a lot of prime numbers and saving them on my pc's HDD. Why not I put prime numbers found by me, although I am not first to find them, on internet some where some day.
.
Therefore I re-ran current version of the application I made for finding primes to find prime numbers under different upper limits and found that for upper limit of 20000000, number/count of prime numbers is nearly above ONE Million. Some out puts of those Prime number searches I am sharing bellow. So far the maximum I reached for continuous list of prime numbers is:
.
  • Range......................: [2 and 32000000002] inclusive
  • Prime numbers found.: [1382799415]
  • Largest prime number: [31999999987]
.
Following is the list of first "6542" prime numbers, under 2^16, I found using software made by me using C# 2010.  I used this upper limit because it reminds me of "unsigned int" of 16 bit computers.
.

.
List of prime numbers under 2^16
.

.
List of prime numbers under 20000000
.
Following are the links to files containing first 1270607 prime numbers I found under 20000000 using software I made in c# 2010.
  1. Prime numbers between 00000000 and 00999999 inclusive
  2. Prime numbers between 01000000 and 01999999 inclusive
  3. Prime numbers between 02000000 and 02999999 inclusive
  4. Prime numbers between 03000000 and 03999999 inclusive
  5. Prime numbers between 04000000 and 04999999 inclusive
  6. Prime numbers between 05000000 and 05999999 inclusive
  7. Prime numbers between 06000000 and 06999999 inclusive
  8. Prime numbers between 07000000 and 07999999 inclusive
  9. Prime numbers between 08000000 and 08999999 inclusive
  10. Prime numbers between 09000000 and 09999999 inclusive
  11. Prime numbers between 10000000 and 10999999 inclusive
  12. Prime numbers between 11000000 and 11999999 inclusive
  13. Prime numbers between 12000000 and 12999999 inclusive
  14. Prime numbers between 13000000 and 13999999 inclusive
  15. Prime numbers between 14000000 and 14999999 inclusive
  16. Prime numbers between 15000000 and 15999999 inclusive
  17. Prime numbers between 16000000 and 16999999 inclusive
  18. Prime numbers between 17000000 and 17999999 inclusive
  19. Prime numbers between 18000000 and 18999999 inclusive
  20. Prime numbers between 19000000 and 20000000 inclusive
Download all 20 files containing all prime numbrs
under 20000000 (prime number count 1270607)
as a zip file
.

.
If there are any mistakes then I will surely remove them whenever found.

I will upload source code of application I made and used for generating above prime numbers in some near-future post some time else.
.


Thursday, August 24, 2017

Happy 5555 PageViews - (2017 Aug 24 Thu)

+ - ------------------------------------------------ - +
| |
| C O N G R A T U L A T I O N S |
| |
| Today |
| On 2017 Aug 24 Thu |
| my this Blog reached 5555 page views mark. |
| |
| A lot of THANKS to |
| Visitors, Viewers, Readers and Wanderers. |
| |
| Please keep visiting this blog |
| and |
| tell others about it. |
| |
| Congratulations to me also. |
| |
+ - ------------------------------------------------ - +


Monday, July 31, 2017

Happy 5000 PageViews - (2017 Jul 31 Mon)


. . . . .
. . . . .
. .
C O N G R A T U L A T I O N S
Today
On 2017 Jul 31 Mon
my this Blog reached 5000 page views mark.
A lot of THANKS to
Visitors, Viewers, Readers and Wanderers.
Please keep visiting this blog
and
Tell others about it.
Congratulations to me also.
. .
. . . . .
. . . . .

Saturday, July 15, 2017

console barmenu -3- c sharp - 170714Fr

  Console BarMenu - 3  
.
(DOS era text-mode style Colorful Bar-Menu in c#)
Version: 170714Fr
.
During the era of DOS 3, creating a bar menu in text or graphic mode was a cutting-edge topic in programming. I vividly remember writing a ".prg" program in dBase III Plus on my institute's PC, which impressed my friends, lab assistants, and teachers. That program was my first attempt at creating a bar menu, and I'm proud to say it was a success. Although I'm not sure if the printout of that program still exists in my archives, I'm not eager to find out also. In memory of that bar menu, I've now recreated that bar menu as a Console project in C#.
.
Salient  features of above mentioned c# project are as follows:
(A) Display bar-menu.
(B) Provide menu-item selection mechanism through navigation keys like Up-arrow, Down-arrow, Home, End and Enter keys.
(C) Process menu-item selection and perform action accordingly.
(D) Return back to menu at end of action processed.
(E) Provide mechanism for exiting from 'bar-menu' and application.
.
Then I tried and made the above required project. Code for achieving above task is simple and is described as follows.
(1) First menu processing method is called. There must be one such method per menu.
(2) Then from menu processing method menu-driver method is called with information like menu-item-list etc.
(3) Then in menu-driver things happen in following sequence:
(3a) First menu is displayed.
(3b) Then user-input is taken.
(3c) Then user-input is processed based on input key as follows:
(3c1) Navigation key: Selected menuitem index is updated.
(3c2) Enter key: Current menuitem index is selected for returning.
(3c3) Escape key: Menu exit code is selected for returning.
(3c4) If user input is not Escape-Key or Enter-Key go back to step 3a.
(3c5) Menu-driver exits when user-input is Escape-Key or Enter-Key.
(4) Back in menu processing method returned value is processed as follows:
(4a) Respective methods are called according to returned value. On return control goes back to step 2.
(4b) Else menu exits when selection code is Escape-Key.
.
Keys used by menu are displayed in menu footer and are described in the following:
Navigation:
Down-arrow key for next menuitem.
Up-arrow key for previous menuitem.
Home key for First menuitem.
End key for last menuitem.
Selection:
Ente key for selecting current menuitem.
Exit:
Escape key for exiting menu.
.
Following is the C# code of the project I described above. It is not so simple or easy to understand. But it is full of helpful comments throughout it.
.

.
Code of "Console BarMenu - 3" in Visual C# 2010
.

.
Application Output
Following are some screen-shots of the application I took at different state of application to explain the application's look and feel.
.
Application is loaded
(When Application is loaded.)
.
.
Application Menu bar navigation
(When selection bar is on first menu-item)
.
(When selection bar is on last menu-item)
.
(When selection bar is on some other menu-item)
.
.
Application Menu item selected
When menu's any selection bar is selected by pressing ENTER key and application is moved to the respective section.
.
(When 'Grains and cereals' menu-item is selected and respective method is run)
.
(When 'Vegetables' menu-item is selected and respective method is run)
.
(When 'Bakery & Confectionery Products' menu-item is selected and respective method is run)
.

.
Method which displays message based on menu selection,  randomly selects background for console screen from a few dark ConsoleColors making display a little colorful.
.

.
A brief overview of Console application:
In the context of C#, a Console Application is a type of program that interacts with users through the command-line interface. This type of application reads input from the user through the standard input stream (STDIN), processes the input, and then displays output to the user through the standard output stream (STDOUT). Additionally, any error messages or exceptions are directed to the standard error stream (STDERR). Console Applications are commonly used for tasks that require user input, such as command-line tools, utilities, and interactive programs. They provide a simple and efficient way to interact with the user, making them a fundamental part of the C# programming landscape.
.

.
If there are any mistakes then I will surely remove them whenever found.
.

.
Enjoy Complete Source code of application written and compiled in visual studio 2010 Ultimate by me. Download it. Extract it. Read 'ReadMeFirst.txt' file and do as is explained in it.
.