Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Dave http://pedotnet.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Calculate 2 to the power of N

// Calculate 2 to the power of N
// Returns "double" value
   1  
   2  
   3  
   4          private double TwoPowerN(int n)
   5          {
   6              int k;
   7              int i = 1;
   8  
   9              for (k=1; k <= n; k++)
  10              {
  11                      i = i * 2;   
  12              }
  13              return i
  14          }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS