Cod sursa(job #1479151)

Utilizator GosulyGosuly Robert Gosuly Data 30 august 2015 17:21:00
Problema Al k-lea termen Fibonacci Scor 0
Compilator c Status done
Runda Arhiva educationala Marime 0.57 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

unsigned long hatLog(unsigned long n,int hat)
{



    if(hat!=1)
    {
        if(hat%2==0)
            return hatLog(n*n,hat/2);
        else
            return hatLog(n*n,hat/2)*n;
    }
    else
        return n;

}
int main()
{
    FILE *readfile,*writefile;
    readfile=fopen("lgput.in","r");
    writefile=fopen("lgput.out","w");

    unsigned long alap;
    int hat;

    fscanf(readfile,"%lu %d",&alap,&hat);


    fprintf(writefile,"%lu",hatLog(alap,hat));
    return 0;
}