static int fibonaci(int level) { if (level <= 1) return 100; else return ((fibonaci(level - 1) + fibonaci(level - 2))); }
int fibonaci(int i){ if(i == 0){ return 0; } if(i == 1){ return 1; } return fibonaci(i-1) + fibonaci(i-2); }
int main (int argc , char **argv){ fibonaci(6); }
int main() { fibonaci(); int j,t,n,k; scanf("%d",&t); while(t--) { j=0; scanf("%d",&n); for(k=0;k<50;k++) { if(a[k]==n) { j=1; break; } } if(j==1) printf("IsFibo\n"); else printf("IsNotFibo\n"); } return 0; }
int main(int argc, char** argv){ int pid, i; for (i = 1; i < argc; ){ int requested_time = atoi(argv[i++]); if(requested_time < 0 || requested_time > 30000){ // ADDED for checker printf("Invalid requested time!!!\n"); exit(1); } int level = atoi(argv[i++]); if(level < 1 || level > 50 ){ printf("Level ERROR!\n"); exit(2); } int fib_num= atoi(argv[i++]); pid = fork(); if (pid < 0) { perror("Fork ERROR!\n"); exit(3); } else if (!pid) { usleep(60000); fibonaci(fib_num); exit(0); } struct sched_param param; param.lshort_params.requested_time = requested_time; param.lshort_params.level = level; int res = sched_setscheduler(pid, SCHED_LSHORT, ¶m); if (res) printf("sched_setscheduler ERROR: ret= %d, errno=%d pid=%d level=%d requested_time=%d, fib_num=%d\n", res, errno, pid, level, requested_time, fib_num); else printf("requested_time=%d level=%d, fib_num=%d, pid=%d\n", requested_time,level, fib_num, pid); } while (wait() != -1); struct switch_info info[LOG_ARRAY_SIZE]; int logs_number = get_scheduling_statistic(info); if (logs_number < 0) { printf("get_scheduling_statistic ERROR: ret=%d, errno=%d\n", logs_number, errno); exit (-1); } printf("prev_pid next_pid prev_policy next_policy time reason\n"); for (i = 0; i < logs_number; i++) printf("%04d %04d %14s %14s %lu %s\n", info[i].previous_pid, info[i].next_pid, policies[info[i].previous_policy], policies[info[i].next_policy], info[i].time, switch_reason[info[i].reason]); return 0; }
void Core::Nibbler::setLevel() { if (this->_food.getScore() >= fibonaci(this->level)) { if (this->level <= 9) this->speed -= this->_food.getScore() * 5; ++this->level; } }
int widgets_recursive::fibonaci(int n) { static int no_known[45] = {0}; if(no_known[n] != 0) return no_known[n]; if(n<0 || n>45) return 0; if(n==0 || n==1) { no_known[n] = 1; return no_known[n]; } else { int nRet = fibonaci(n-1)+fibonaci(n-2); no_known[n] = nRet; return nRet; } };
void recursion_test() { printf("factorial of 8 is: %d\n", factorial(8)); int i; printf("fibonaci of %d is: ", SIZE); for (i=0; i<10; i++) { printf("%d\t", fibonaci(i)); } printf("\n"); }
int main() { vector<int> numbers; string name; int entry1 = 0; int entry2 = 0; int n; cout << "Enter two numbers to begin a fibonaci sequence. "; cin >> entry1 >> entry2; cout << "\nPlease the number of integers for this fibonaci sequence. "; cin >> n; cout << " The fibonacci sequence for these two starting numbers is: "; fibonaci(entry1, entry2, numbers, n); print(name, numbers); }
int fibonaci(int n) { if (n < 2) { return n; } return fibonaci(n-1) + fibonaci(n-2); }
int main(int argc, char const *argv[]) { int pid = getpid(); int res = 0; if((argc - 1) % 2 != 0) return -1; int tasks_num = (argc - 1) / 2; printf("task num: %d", tasks_num); test_task tasks[tasks_num]; int current = 0; struct sched_param sp; int i; for( i= 1; i <= tasks_num; i++) { test_task tt; tt.trials = atoi (argv[i*2 - 1]); tt.fnum = atoi (argv[i*2]); tt.pid = fork(); if(tt.pid == 0) { int cpid = getpid(); sp.sched_priority = 1; sp.requested_time = 2; sp.number_of_trials = tt.trials; sched_setscheduler(tt.pid, SCHED_SHORT, &sp); printf("test pid:\n"); printf("================\n"); res = is_SHORT(cpid); printf("is_SHORT res = %d;\terrno = %d;\tpid = %d\n", res, errno, cpid); res = remaining_time(cpid); printf("remaining_time res = %d;\terrno = %d;\tpid = %d\n", res, errno, cpid); res = remaining_trials(cpid); printf("remaining_trials res = %d;\terrno = %d;\tpid = %d\n", res, errno, cpid); if (!fork()){ return 0; } fibonaci(tt.fnum); return 0; }else if(tt.pid > 0) { tasks[current].pid = tt.pid; tasks[current].trials = tt.trials; tasks[current++].fnum = tt.fnum; } } int status = 0; res = 0; struct switch_info si[150] = {0}; for(i = 0; i < tasks_num; i++) { printf("waiting for %d\n", tasks[i].pid); res = waitpid(tasks[i].pid, &status, 0); } int size = get_scheduling_statistic(si); print_test_results(si, size, tasks, tasks_num); printf(" res = %d;errno = %d\n", res, errno); return 0; }
void main() { int n; scanf("%d",&n); printf("%d",fibonaci(n)); getch(); }
int fibonaci(int n) {if(n<=1) return n; else return fibonaci(n-1)+fibonaci(n-2); }
int main(){ int i, returnval; returnval = fibonaci(6) - 2; return returnval; }