I know to write a program to print the fibonacci series. But the problem is my teacher has asked us to write a program to print the natural numbers that are not involved in the fibonacci series.
For example if the user gives 7 terms of the series to be displayed,
then the display of the fibonacci series is 0, 1,1, 2, 3, 5, 8.
But the natural numbers not involved are 4, 6 and 7. That's what my teacher wants.
But I am struggling to write a program to perform this particular operation. Can anyone help?
8 10951
Try to generate the fibonacci series upto the range of the given number and store it in an array. Then using the for loop find the numbers that are not involved in the fibonacci series and print
Ya I know that logic but when I tried to put it down in coding, I feel that somewhere I have gone wrong in the coding. Why don't you send me the coding so that I can see if mine tallies with yours or otherwise where I have gone wrong. Later I will post my coding so that you can spot out where I am having problem because right now I am preparing for exam. In the mean time, I would appreciate if you could send in your coding for this program.
Try out with this ... U will get the ans
#include<stdio.h>
int main()
{
int f1,f2,f3,k,n;
printf("Enter the last element\n");
scanf("%d",&n);
f1=1;
f2=2;
f3=f1+f2;
while(f3<n)
{
f1=f2;
f2=f3;
f3=f1+f2;
k=f2;
while(k<f3-1 && k<=n-1)
{
k++;
printf("%4d",k);
}
}
return 0;
}
Try out with this ... U will get the ans...
#include<stdio.h>
int main()
{
int f1,f2,f3,k,n;
printf("Enter the last element\n");
scanf("%d",&n);
f1=1;
f2=2;
f3=f1+f2;
while(f3<n)
{
f1=f2;
f2=f3;
f3=f1+f2;
k=f2;
while(k<f3-1 && k<=n-1)
{
k++;
printf("%4d",k);
}
}
return 0;
}
thanks I will try it out soon
Wow, it is working...thanks a lot and I really appreciate that help
Wow, it is working...thanks a lot and I really appreciate that help
It's ok....
And thanks for the complements...
You may try this program to get natural numbers like 4,7 in a fibonacci series: #include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
unsigned long a,b,c,n;
a=2;
b=1;
cout<<"How many numbers(>5)?"<<"\n";
cin>>n;
cout<<"Fibonacci series"<<"\n";
cout<<a<<b;
for(int i=2,i<n;i++)
{
c=a+b;
cout<<c;
a=b;
b=c;
}
getch();
return 0;
}
The Output will be as:
2134711
By giving b=2,You will get the output as:
22461016
In this way you can get the natural numbers like 4,6,7 in a fibonacci series.
We can't get a series with 4,6,7 coming together,since the sum of 4 and 6 will certainly give as 10 and not as 7.
I hope that this helped you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sriram Krishnan [at] gmx [dot] net |
last post by:
Given an arbitrary number series, how do I identify the series and find the
Nth number...
for e.g 1,3,5,7 is an AP and the next number will be 9
1,8,27,64 is the series of cubes and the next will...
|
by: YS Sze |
last post by:
If you know the exact longitude and latitude for a specific
location, would anyone think it'd make any sense to find out if this
set of location numbers is really part of the Fibonacci series or...
|
by: CII |
last post by:
Hi everybody. I've been reading posts a year old about the fibonacci
series right on this newsgroup, and while it's not directly games
related, I'll share my own notes as well.
On another...
|
by: MARQUITOS51 |
last post by:
Hey guys this is the fibonacci series. But Im having this huge problem.
First of all I want to do the simplest code possible so then I can use
user defined functions and arrays. But this one didnt...
|
by: student |
last post by:
Hi guys,
please tell me how to write the iterative version of fibonacci series using a stack.
Thanks
|
by: greek |
last post by:
Hi!
I hav to generate fibonaaci series using recursion:
0,1,1,2,3,5,8,18,21...
whr
fibonacci(0)=0
fibonacci(1)=1
fibonacci(n)=fibonacci(n-1)+fibonacci(n-2)
ive witten the code but having 2...
|
by: hollowspook |
last post by:
Hi, there
a = range(100)
if I want to use No 7, 11, 56,90 in a, then the only way I do is ,
a, a, a].
Is there any other way?
Thanks in advance.
|
by: veeru |
last post by:
Hi All,
Can anyone tell about how to create a FIBONACCI series in VB.Net and C#
Thanks in Advance,
Veeru
|
by: deepner |
last post by:
plz help to find why the program showing fibonacci(non-recursively) is running infinitely
#include<iostream>
#include<conio.h>
using namespace std;
unsigned int fibo(int a,int b)
{
unsigned...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |