Connect Me

twitterfacebookgoogle plus email

  Instagram View Biwas Bhattarai's profile on LinkedIn

Hailstone Series

3,10,5,16,8,4,2,1,4,2,1......................... is a series called 'Hailstone series'. It is a mathematical series in which the first number is checked for Even or Odd. If the number is odd, next number is 3 times plus 1 [(ax3)+1], and if the number is Even, next number is half of that number (a/2). Eventually, the series comes to end at 1.
#include<stdio.h>
#include<conio.h>
int main()
{
int x=3, i;
printf("Hailstone Series:\n");
for(i=1;i<=15;i++)
{
printf("%d\t",x);
if(x % 2==0)
x=x/2;
else
x=(x*3)+1;
}
getch();
}
Ą
https://www.flickr.com/photos/spklg/15211044551/