MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

CSES_Problems/Weird_Algorithm/solution.c:2–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include<stdio.h>
2int main()
3{
4long long int num; //declaring number as long long integer
5scanf("%lld",&num);
6
7printf("%lld",num);
8
9while(num!=1) //loop works until number is not equals to 1
10{
11if(num%2==0) //if number is even
12num=num/2; //dividing the number by 2
13
14else //else number is odd
15num=(num*3)+1; //multiplying the number by 3 and then adding 1 to it
16
17printf(" %lld",num); //printing the result
18}
19}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected