Hello friends!!!!!
Hail stone series
Blog post description.
C LANGUAGE
10/26/20241 min read
//C pgr to print the hailstone sequence
#include <stdio.h>
int main() {
int a;
printf("Enter the value of number : ");
scanf("%d", &a);
while (a > 1) {
if (a % 2 == 0) {
a = a/2;
} else {
a = 3*a + 1;
}
printf("%d\n", a); // Print the current value of a
}
return 0;
}
Output:
n = 23
70
35
106
53
160
80
40
20
10
5
16
8
4
2
1
=== Code Execution Successful ===