Important consideration before accepting a Development job offer


You should consider the following acceptance criteria before making a decision to take a Software development job offer.

If the company uses Source Control Management.

If the company follows Software Development cycle

If the company uses Continuous integration system

If the company has Senior/Principal Software Engineer/Architect

If you need to work in a team or alone

If the company has QA (Quality Assurance) team

If you need to overwork.

Courtesy: Shah Ali Newaz (Topu) vai

Top and Most commonly used Git commands you should know


Currently, I am using MacOS-X 10.9; though I believe the following commands will work irrespective of your Hardware and OS. I grouped the commands by their relevancy and their necessity base (basic commands first). The target audience are developers, who know git theoretically and also use git in day to day work but having hard time remembering the commands.

After successful Installation:

check to see where is the git located

~$ which git
/usr/bin/git

the version of the git installed

~$ git --version
git version 1.8.3.4 (Apple Git-47)

Configuration:

System wide git configuration file path: /etc/gitconfig
This file is not used or modified commonly.

file path for Windows: Program files\Git\etc\gitconfig

User git configuration file path: ~/.gitconfig
file path for Windows: $HOME\.gitconfig

Project git configuration file path: PROJECT/.git/config

set user name (User configuration)

~$ git config --global user.name "YOUR USER NAME" 

--global [indicates User configuration, not System configuration]
--system [indicates System wide configuration]

set user email id (User configuration)

~$ git config --global user.email "YOUR EMAIL ID"

set default text editor for git

~$ git config --global core.editor "textedit -wl1"

-w [indicates, git should wait for next task until editor is closed]
l1 [indicates, the text editor will put the cursor at line 1 when starts]

use colors with git command line

~$ git config --global color.ui true

Current status of configuration

~$ git config --list
user.name=shahab.uddin
user.email=tausiq19@gmail.com
editor="textedit -wl1"
color.ui=true

Auto Completion for Git:

Windows already have Auto completion feature already. So the instruction are for Mac and Unix user only

Download the completion file form Github

~$ cd ~
~$ curl -0L https://github.com/git/git/raw/master/contrib/completion/git-completion.bash

Rename file

~$ mv ~/git-completion.bash ~/.git-completion.bash

Open bash profile file

~$ nano .bash_profile

Edit bash profile file
add this code to the file

if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
fi

now hit: ctrl + x to close the file
now hit: y to say, yes I want to save the file
now hit: enter to go back
restart terminal (quit and open again)

Git Help:

Open git help

~$ git help

Open git help for specific command

~$ git help log

hit f to move forward
hit b to move backward
hit q to quit

Starting Git

Initialize a project
Select a folder where you would like to create a project (that folder will be tracked by Git).
On terminal go to that folder (write cd and drag drop the folder)

~$ git init
Initialized empty Git repository in /Users/Documents/Sourcecode/Git/first_git_project/.git/

Look inside what Git Initialized

~$ ls -la
total 0
drwxr-xr-x   3 Shahab  staff  102 Nov 24 22:17 .
drwxr-xr-x   3 Shahab  staff  102 Jul 14 05:12 ..
drwxr-xr-x  10 Shahab  staff  340 Nov 24 22:15 .git
~$ ls -la .git/
total 24
drwxr-xr-x  10 Shahab  staff  340 Nov 24 22:15 .
drwxr-xr-x   4 Shahab  staff  136 Nov 24 22:17 ..
-rw-r--r--   1 Shahab  staff   23 Nov 24 22:15 HEAD
drwxr-xr-x   2 Shahab  staff   68 Nov 24 22:15 branches
-rw-r--r--   1 Shahab  staff  138 Nov 24 22:15 config
-rw-r--r--   1 Shahab  staff   73 Nov 24 22:15 description
drwxr-xr-x  11 Shahab  staff  374 Nov 24 22:15 hooks
drwxr-xr-x   3 Shahab  staff  102 Nov 24 22:15 info
drwxr-xr-x   4 Shahab  staff  136 Nov 24 22:15 objects
drwxr-xr-x   4 Shahab  staff  136 Nov 24 22:15 refs

Add files to Git

~$ git add .

. [indicates that all files inside the directory will be added to Git]

~$ git add firstFile.txt

First commit with Git

~$ git commit -m "Initial commit"
[master (root-commit) 468be11] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 firstFile.txt

-m [indicates that we are going to add a message next]

Few tips on commit messages

  • write commit messages is present tense, not past tense.
  • write “fix bug” or “fixes bug”, not “fixed bug”
  • you can add bullet points using asterisks or hyphen
  • Its a good idea to add ticket tracking numbers/ bug report number with commit
  • Be clear and descriptive
  • for example,
    Bad: “Fix typo”
    Good: “Add missing > in project section of HTML”
  • another example,
    Bad: “Update login info”
    Good: “Change user authentication to Blowfish”

A good commit message example

t23094 – Fixes bug in admin logout

When an admin logged out of the admin area, they could not log in to the members area because their session[:user_id] was still set to the admin ID. This patch fixes the bug by setting session[:user_id] to nil when any user logs out of any area.

Git Log

View the last commits

~$ git log
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

View the last commits upto limited number

~$ git log -n 1
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

-n 1 [it will show the last 1 commit]

View the last commits since up to a date

~$ git log --since=2013-11-23
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

View the last commits until a date

~$ git log --until=2013-11-25
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

View the commits of a particular author

~$ git log --author="shahab.uddin"
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

View the commits with a regular expression

~$ git log --grep="Init"
commit d68b938b21642db657d23b8b6bcf4da310635ee5
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sun Nov 24 22:22:01 2013 +0600

    Initial commit

Find out where is the HEAD pointing now

~$ git log HEAD
commit 468be1105dc2190f76335fcdb3f708a58ecaafaf
Author: shahab.uddin <tausiq19@gmail.com>
Date:   Sat Dec 14 00:22:21 2013 +0600

    Initial commit

Git Diff

View the difference of the working directory

~$ git diff
diff --git a/firstFile.txt b/firstFile.txt
index 55d1db5..8ee1b5a 100644
--- a/firstFile.txt
+++ b/firstFile.txt
@@ -1 +1,3 @@
 This is my First File.
+
+I have changed this portion of text.

Scenario
1. You have created a file (firstFile.txt)
2. made some changes to that file
3. add it to the staging index ( using, git add . or, git add firstFile.txt )
4. make some more changes to firstFile.txt
5. Now you would like to view the difference between the staged index and working directory
6. the above command means, show me the difference between the staging index and present working copy

[to see the difference of a specific file, use git diff firstFile.txt ]

View the difference of the staging index

~$ git diff --staged
diff --git a/firstFile.txt b/firstFile.txt
index 55d1db5..8ee1b5a 100644
--- a/firstFile.txt
+++ b/firstFile.txt
@@ -1 +1,3 @@
 This is my First File.
+
+I have changed this portion of text.

Scenario:
1. you have added a file to the staging index, for the 2nd time
2. now you would like to view the changes you made on the 2nd time
3. the above command means, what are the changes in my repository and staging index

Remove file from Git

Remove file form Git repository

Removing a file from git repository is a two step process.
1. remove the file from git repository
2. make a commit that you have removed the file

~$ git rm firstFile.txt
rm 'firstFile.txt'
~$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	deleted:    firstFile.txt
#
~$ git commit -m "first file removed"
[master c80278c] first file removed
 1 file changed, 3 deletions(-)
 delete mode 100644 firstFile.txt

To be continued

Acknowledgment: Kevin Skoglund from lynda.com

Collected Quotation


  • I believe in being part of the solution, not the problem

     

  • Be the change you want to see in the world

     

  • Don’t hate what you don’t understand

     

  • God never shuts one door without opening another

     

  • The biggest mistake I have made in my life is letting people stay in my life far longer than they deserved to.

     

  • Love her for who she is, not who you want her to be

     

  • The prettiest smiles hide the deepest secrets. The prettiest eyes have cried the most tears, and the kindest hearts have felt the most pain

     

  • Counting other people’s sins, does not make you a saint

     

  • The two most important days in your life are the day you are born .. and the day you find out why. _ mark twain

     

  • If you left me without a reason, don’t come back with an excuse

     

  • We keep running after people who care the least about us. Why don’t we just stop, turn around and see the ones running behind us?

     

  • I am choosing to ignore you, forget you and move on, then I realized that by trying to forget you, all I did was think of you

     

  • Sometimes its easier to pretend you’re happy rather that explain why you’re not

     

  • Dreams is not what you see in sleep is the thing which doesn’t let you sleep

     

  • A wrong relationship will make you feel more alone than when you were single

     

  • A woman’s loyalty is tested when her man has nothing .. a man’s loyalty is tested when he has everything

     

  • I said I’m over you but everything my phone vibrates I still wish is a text from you

     

  • তুমি যদি কাউকে ভালবাস, তবে তাকে ছেড়ে দাও। যদি সে তোমার কাছে ফিরে আসে, তবে সে তোমারই ছিল, আর যদি না ফিরে আসে, তবে সে কখনই তোমার ছিল না …

     

  • Real eyes, Realize, Real lies

     

  • Life is like a roller coaster. It has its ups and downs. But it’s your choice to scream or enjoy the ride.

     

  • Life is not a problem to be solved, but a reality to be experienced

     

  • Always wrong persons teach the right lessons of life

     

  • The race is not over. Because I have not won yet …

     

  • A true relationship is someone who accepts your past, supports your present, loves you & encourages your future.

     

  • Don’t say “there’s still time” or “maybe next time’ because there’s also the concept of “it’s too late”

     

  • It’s painful to say good-bye to someone that you don’t want to let go. But it’s more painful to ask someone to stay if you know they really want to go

     

  • They say: you don’t know what you’ve got till it’s gone. Truth: You knew exactly what you had; you just thought you’d never lose it

     

  • History repeats itself. Liars will be liars, cheaters will be cheaters, and the person who has always been there for you, will always be.

     

  • I believe Allah has a bigger plan for me than I had for myself

     

  • Hurt a true HEART as many times you want, it won’t stop LOVING you. But if you cheat a TRUE HEART, it won’t HURT or HATE you, but it won’t ever dare to LOVE anyone again…!!

     

  • The greater your storm, the brighter you rainbow

     

  • I will win, not immediately, but definitely

     

  • No one is busy in this world. It is all about priorities !!!”

     

  • Apology doesn’t mean that you were wrong, or the other person was right. It means that your relationship is valuable than your ego

     

  • Never reject 3 people: leo, Gemini, aquarious. They are true, honest friends never believe in 3 people. Taurus, aries, pisces. They are the most selfish & mean never lose 3 people. Sagittarius, cancer, Capricorn. They r the most sincere n true lovers. never leave 3 people. Virgo, libra, scorpio. They can keep secrets, frndship, they can never see ur tears

     

  • Adjustment with right people is always better than argument with wrong people…. and Meaningful silence is always better than meaningless words…..!

     

  • Any man can be a father. But it takes someone special to be a dad

     

  • Sometimes god doesn’t give you what you think you want, not because you don’t deserve it, but because you deserve better

     

  • No one has ever become poor by giving

     

  • When God gives you a vision, he also gives you the provision needed to fulfill it.

     

  • The more you know, the more you realize you don’t know

     

  • Every new day is another chance to change your life.

     

  • Do not educate your child to be rich. Educate him to be happy. So when he grows up, he’ll know the value of things, not the price.

     

  • Love is a cycle when you love, you get hurt. when you get hurt, you hate. when you hate, you try to forget. when you try to forget, you start missing.. and when you start missing you’ll eventually fall in love again

     

  • Don’t use the sharpness of your speech on the mother who taught you how to speak

     

  • A woman who doesn’t ask for anything.. deserves everything

     

  • A real relationship has fights, trust, faith, tears, pains, arguments, patience, secrets, jealousy & love.

     

  • Nobody can go back and start a new beginning, but anyone can start today and make a new ending

     

  • Dad my hero. papa you stood by me all the time, you’ve picked me up when I was down, you are my ray of sunshine and I will always love you. Thank you so much for everything.

     

  • An intelligent person does not need the promise of heaven to see the merit in good deeds

     

  • Never choose me without understanding and never loose me because of misunderstanding… I may be wrong sometime somewhere but not every time everywhere

     

  • খুব কাছের মানুষের অবহেলা সহ্য করার ক্ষমতা মানুষের নেই- মানুষ বড় অভিমানী প্রানী। – হুমায়ুন আহমেদ

     

  • “Anger is like gasoline. If you spray it around and somebody lights a match, you’ve got an inferno. But if we can put our anger inside an engine, it can drive us forward.” — Scilla Elworthy

     

Trip To Nepal With KAZ Software


Tribhuvan International Airport (United Airlines BD Ltd.)

Tribhuvan International Airport (United Airlines BD Ltd.)

My First Air Journey

Hotel Marshyangdi

Hotel Marshyangdi

Hotel Marshyangdi @Thamel, Kathmandu

Nepal Highway

Nepal Highway

Nepal Highway

Cable Car

Cable Car

First Cable Car Experience

Monokamona Mondir

Monokamona Mondir

Monokamona Mondir

Mt. Machhapuchhre

Mt. Machhapuchhre

Mt. Machhapuchhre (behind the hills)

Trishul River

Trishul River

we did Water Rafting in this river named Trishul. Dont have any picture of that as we were Rafting!


Key points: 
1. The best deal (according to local personnel) would be, visit Monokamona Mandir and Enjoy rafting in a day on the way from Kathmandu to Pokhara.

2. During tourist seasons prices are too high in Nepal. For shopping, you should stroll places where tourist density is relatively low. (i found Devi's falls@Pokhara area is cheaper than Lakeside@Pokhara) 

3. Halal foods are not so available in the world's only constitutionally declared Hindu country. Some restaurants authority do not even know what the halal food is. so, double check even if they assure you that the food is halal. You can always choose veg over non-veg for safety. 
Nepali Thali and Momo are the two famous traditional food. 

UVa : 116 (Unidirectional TSP)


Title : Unidirectional TSP

Link : UVa 116

Tricky Lines :

If there is more than one path of minimal weight the path that is lexicographically smallest should be output.

Analysis :

  1. Calculate the sum from last column to first column
  2. u will get the lexicographically smallest path
  3. there is only 3 possible paths from a cell
  4. for example : if the dimension is row * column
  5. from cell [i] [j] u can go 3 possible path :
    • cell [(row + i - 1) % row] [j + 1];
    • cell [i] [j + 1];
    • cell [(row + i + 1) % row] [j + 1];
  6. suppose, u can go cell ‘c’, from cell ‘a’ and ‘b’
  7. and both path produces same path cost
  8. then update path for ‘c’, whichever is smallest, ‘a’ or ‘b’

Runtime : 0.116s

Solution :


// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define pi acos(-1.0)
#define N 1000000
#define LL unsigned long long
using namespace std;

struct cell {
    int val;
    int child;
} matrix [10 + 3] [100 + 3];
int row, col;

void reset ()
{
    for ( int i = 0; i < row; i++ ) {
        for ( int j = 0; j < col; j++ )
            matrix [i] [j].child = -1;
    }
}

int main ()
{
    while ( scanf ("%d %d", &row, &col) != EOF ) {

        reset ();

        for ( int i = 0; i < row; i++ ) {
            for ( int j = 0; j < col; j++ ) scanf ("%d", &matrix [i] [j].val);
        }

        for ( int j = col - 2; j >= 0; j-- ) {
            for ( int i = 0; i < row; i++ ) {
                int thisNum = matrix [i] [j].val;

                matrix [i] [j].val = thisNum + matrix [(row + i - 1) % row] [j + 1].val;
                matrix [i] [j].child = (row + i - 1) % row;

                int sum = thisNum + matrix [i] [j + 1].val;
                if ( sum < matrix [i] [j].val ) {
                    matrix [i] [j].val = sum;
                    matrix [i] [j].child = i;
                }
                else if ( sum == matrix [i] [j].val && matrix [i] [j].child > i ) matrix [i] [j].child = i;

                sum = thisNum + matrix [(row + i + 1) % row] [j + 1].val;
                if ( sum < matrix [i] [j].val ) {
                    matrix [i] [j].val = sum;
                    matrix [i] [j].child = (row + i + 1) % row;
                }
                else if ( sum == matrix [i] [j].val && matrix [i] [j].child > (row + i + 1) % row ) matrix [i] [j].child = (row + i + 1) % row;
            }
        }

        int lowest = INT_MAX;
        int lowest_row;

        for ( int i = 0; i < row; i++ ) {
            if ( matrix [i] [0].val < lowest ) {
                lowest = matrix [i] [0].val;
                lowest_row = i;
            }
        }

        vector <int> path;

        for ( int i = 0; i < col; i++ ) {
            path.push_back (lowest_row + 1);
            lowest_row = matrix [lowest_row] [i].child;
        }

        bool space = false;
        for ( size_t i = 0; i < path.size (); i++ ) {
            if ( space ) printf (" ");
            space = true;
            cout << path [i];
        }
        cout << endl;
        cout << lowest << endl;
    }

	return 0;
}

// @END_OF_SOURCE_CODE

Publish code in wordpress


Publish code in WordPress is a really simple task. Here are the steps

Step 1: Open a new post  
    1.1: or you can post code in comment section 
    
Step 2: Select Text; not Visual 
    2.2: in case of comment you don't need to do this 
    
Step 3: write / paste code as shown in the picture 

update 1: "HTML" now changed to "Text" 

update 2: you can write only "code" instead of "sourcecode"  
Code

Code in Post

Output


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

language
actionscript3
bash
clojure
coldfusion
cpp
csharp
css
delphi
erlang
fsharp
diff
groovy
html
javascript
java
javafx
matlab (keywords only)
objc
perl
php
text
powershell
python
r
ruby
scala
sql
vb
xml

collapse
true/false
– If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Good for
large code posts. Defaults to false.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

firstline
number
– Use this to change what number the line numbering starts at. It defaults to 1.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

gutter
true/false
– If false, the line numbering on the left side will be hidden. Defaults to true.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

highlight
comma-seperated list of numbers
– You can list the line numbers you want to be highlighted. For example “4,7,19″.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

htmlscript
true/false
– If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as PHP inside of HTML. Defaults to false and will only work with certain code languages.

light
true/false
– If true, the gutter (line numbering) and toolbar (see below) will be hidden. This is helpful when posting only one or two lines of code. Defaults to false.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

padlinenumbers
true/false/integer
– Allows you to control the line number padding. true will result in automatic padding, false will result in no padding, and entering a number will force a specific amount of padding.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

title
string
– Set a label for your code block. Can be useful when combined with the collapse parameter.


public class HelloWorld
{
    public static void main (String args[]) {
        
        System.out.println("Hello World");
    }
}

source: http://en.support.wordpress.com/code/posting-source-code/

Website links : Saidul Islam


Some essential Links by Saidul Islam (CSE, UIU)

Linux + Gnome + Programming Language (Java / MySql / PHP / C / C++) + PSI + Compiz + Robotics + Xp visual Style + Flash Tutorial + …

Sieve of Eratosthenes


সীভের এই অ্যালগোরিদমটি প্রাইম সংখ্যার তালিকা বের করার জন্য ব্যবহার করা হয় ।
মোটামুটিভাবে ১০ লক্ষ বা ১ কোটির জন্য এটি বেশ ভাল কাজ করে ।
কিন্তু এর চেয়ে বেশি হলে সেটা টাইম লিমিট ক্রস করতে পারে ।

Complexity: O (n logn * loglogn)

ধাপ :
১. প্রথমে ২ থেকে শুরু করে N পর্যন্ত সংখ্যাগুলোর একটি তালিকা করতে হবে ।
২. এই তালিকা থেকে যেগুলো ২ এর গুনিতক সেগুলো বাদ দিতে হবে ।
৩. বাকী সংখ্যা গুলো থেকে যেগুলো ৩ এর গুনিতক সেগুলো বাদ দিতে হবে ।
৪. এইভাবে square root (N) পর্যন্ত সংখ্যাগুলোর গুনিতক বাদ দিতে হবে।
৫. তালিকায় অবশিষ্ট সংখ্যাগুলোর সবগুলোই প্রাইম !!

উদাহরন :

ধরি, N = 30
list: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30.
Square root of N = 6

তাহলে ২ থেকে ৬ পর্যন্ত সংখ্যা গুলোর গুনিতক এই তালিকা থেকে বাদ দিতে হবে।
প্রথমে ২ এর গুনিতকগুলো বাদ দিলে তালিকাটি হবে এরকম :

list: 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29.

এবার ৩ এর গুনিতকগুলো বাদ দিলে হবে :

list: 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29.

এবার ৪ এর গুনিতক বাদ দিতে হবে । কিন্তু ২ এর গুনিতক বাদ দেয়ার সময় ৪ এর গুনিতকগুলো বাদ হয়ে গেছে। তাই আলাদা করে ৪ এর গুনিতক বাদ দেয়ার কিছু নেই।

এবার ৫ এর গুনিকত বাদ দিতে হবে :

list: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.

এবার ৬ এর গুনিতক । একইভাবে, ২ এর গুনিতক বাদ দেয়া মানে ৬ এর গুনিকত বাদ হয়ে যাওয়া ।

অর্থ্যাৎ এবার তালিকায় যতগুলো সংখ্যা আছে তার সবগুলোই প্রাইম

আরো জানার জন্য, http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

void sieve ()
{
    int N = 1000000;

    bool mark [N];
    memset (mark, true, N + 2);

    mark [0] = mark [1] = false;

    for ( int i = 4; i < N + 2; i += 2 )
        mark [i] = false;

    for ( int i = 3; i * i <= N + 2; i += 2 ) {
        if ( mark [i] == true ) {
            for ( int j = i * i; j < N + 2; j += 2 * i )
                mark [j] = false;
        }
    }
}

লাইন ৫ : ১০ লক্ষ এলিমেন্টের একটি বুলিয়ান অ্যারে ।
এটিই আমাদের লিস্ট / তালিকা

লাইন ৬ : সবগুলো এলিমেন্ট ট্রু দিয়ে ইনিশিয়ালাইজ করা হল

লাইন ৮ : ০ এবং ১ প্রাইম নয়। তাই এগুলো ফলস করে দিলাম

লাইন ১০ – ১১ : ২ বাদে সকল জোড় সংখ্যা ফলস করে দিলাম
মানে, ২ এর সকল গুনিতক বাদ দিয়ে দিলাম
জোড় সংখ্যাগুলোর মধ্যে একমাত্র প্রাইম হলো ২

লাইন ১৩ : ৩ থেকে শুরু করে Square root of (N)পর্যন্ত লুপ চলবে
কারন এই সংখ্যাগুলোর গুনিতক তালিকা থেকে বাদ দিব
যেহেতু সকল জোড় সংখ্যা আমরা আগেই বাদ দিয়েছি তাই ‘i’এর মান ২ করে বাড়ছে

লাইন ১৪ : যদি mark [i] == true হয় তার মানে হল ‘i’এখনও কাটা হয়নি
তার মানে, ‘i’একটি প্রাইম এবং ‘i’ এর সকল গুনিতক বাদ দিতে হবে

লাইন ১৫ : প্রথমে নিচের লাইনটি লক্ষ্য করি,

for ( int j = 2 * i; j < N + 2; j += i )
mark [j] = false;

'i' এর দ্বিগুন থেকে শুরু করে একেবারে N পর্যন্ত সকল 'i' এর গুনিতক বাদ যাচ্ছে
কাজ দ্রুততর করার জন্য আমরা 'i' * 'i' থেকে শুরু করেছি
কারন এরচেয়ে ছোট 'i''র গুনিতকগুলো আগেই বাদ পড়েছে

যেমন ধরি, 'i' = ৩
তাহলে, ৩ * ২ = ৬ আগেই বাদ পড়েছে, কারন ২ এর একটি গুনিতক ৬

আবার 'i' = ৫ হলে,
৫ * ২ = ১০ আগেই বাদ পড়েছে, কারন ২ এর একটি গুনিতক ১০
৫ * ৩ = ১৫ আগেই বাদ পড়েছে, কারন ৩ এর একটি গুনিতক ১৫ এবং
'i''র মান ৫ হবার আগেই ৩ হয়েছিল এবং তখন ১৫ বাদ পড়েছে

আরেকটি বিষয় হল, এই লুপটিতে 'i' কিন্তু সর্বদা একটি বিড়োজ সংখ্যা
'i' * 'i' = একটি বিজোড় সংখ্যা হবে
তাই আমরা j += iনা করে j += 2 * i করেছি
কারন, একটি বিজোড় সংখ্যার সাথে আর একটি বিজোড় সংখ্যা যোগ করলে
সেগুলো একটি জোড় সংখ্যা উৎপন্ন করে।
'i' * 'i' = বিজোড়, এর সাথে 'i' যোগ করলে একটি জোড় উৎপন্ন হবে।
আর জোড় সংখ্যা গুলো আমরা আগেই বাদ দিয়েছি।

এবার mark [i] == true হলে i একটি প্রাইম
আর, mark [i] == false হলে i প্রাইম নয়।