-
Notifications
You must be signed in to change notification settings - Fork 0
/
46John1.c
38 lines (32 loc) · 856 Bytes
/
46John1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Roll no:46
Batch:B
Author Name:John Joy
Date:2/09/23
Description:Determine if no is in Fibonacci sequence
*/
#include <stdio.h>
int main() {
int data, num1 = 0, num2 = 1, temp, flag = 0;
printf("Enter ur input:");
scanf("%d", &data);
if (data == num1 || data == num2) {
printf("%d is a fibonacci number\n", data);
return 0;
}
while (num2 <= data) {
temp = num2;
num2 = num1 + num2;
num1 = temp;
if (num2 == data) {
flag = 1;
break;
}
}
if (flag) {
printf("%d is a fibonacci number\n", data);
} else {
printf("%d is not a fibonacci number\n", data);
}
return 0;
}