Algorithms_in_C  1.0.0
Set of algorithms implemented in C.
sol1.c File Reference

Problem 14 solution More...

#include <stdio.h>
#include <stdlib.h>
Include dependency graph for sol1.c:

Functions

long long collatz (long long start_num)
 Computes the length of collatz sequence for a given starting number.
 
int main (int argc, char **argv)
 Main function.
 

Detailed Description

Problem 14 solution

Author
Krishna Vedala

Since the computational values for each iteration step are independent, we can compute them in parallel. However, the maximum values should be updated in synchrony so that we do not get into a "race condition".

To compile with supporintg gcc or clang, the flag "-fopenmp" should be passes while with Microsoft C compiler, the flag "/fopenmp" should be used. If you are using the provided CMAKE compilation, it will automatically detect OPENMP and compile with it for you.

Automatically detects for OPENMP using the _OPENMP macro.