斐波那契 #1

Open
p7h5mgpwv wants to merge 2 commits from 斐波那契数列 into master
Collaborator

#include<stdio.h>
int fib(int n)
{
int f1=1;
int f2=1;
int fn,i;
if(n==1||n==2)
return 1;
for(i=3;i<=n;i++)
{
fn=f2+f1;
f1=f2;
f2=fn;
}
return fn;
}
int main()
{
int n;
int i;
int fn;
scanf("%d",&n);
fn=fib(n);
printf("%d",fn);
}

#include<stdio.h> int fib(int n) { int f1=1; int f2=1; int fn,i; if(n==1||n==2) return 1; for(i=3;i<=n;i++) { fn=f2+f1; f1=f2; f2=fn; } return fn; } int main() { int n; int i; int fn; scanf("%d",&n); fn=fib(n); printf("%d",fn); }
p7h5mgpwv added 1 commit 4 years ago
p7h5mgpwv added 1 commit 4 years ago
This pull request can be merged automatically.
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: p5fom6l7v/htu2#1
Loading…
There is no content yet.