Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Problem 14 solution More...
#include <stdio.h>
#include <stdlib.h>
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. | |
Problem 14 solution
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.
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.