Skip to content
Permalink
bc4cf004c6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
25 lines (19 sloc) 399 Bytes
#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
uint64_t iterfibonacci(uint64_t n)
{
uint64_t x=1, y=1, z=1, counter;
for (counter = 2; counter < n; ++counter) {
z = x + y;
x = y;
y = z;
}
return z;
}
int main(int argc, char** argv)
{
uint64_t n = strtoull(argv[1], NULL, 0);
printf("Fibonacci(%" PRIu64 ") = %" PRIu64 "\n", n, iterfibonacci(n));
return EXIT_SUCCESS;
}