My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Thanks Tree2Thanks
  • 1 Post By topsquark
  • 1 Post By Denis
Reply
 
LinkBack Thread Tools Display Modes
March 9th, 2019, 11:24 AM   #1
Banned Camp
 
Joined: Nov 2018
From: Mumbai

Posts: 32
Thanks: 1

Reverse Fibonacci series.

Reference :

https://www.programiz.com/c-programm...bonacci-series

Can we write a computer program which
will print reverse Fibonacci series numbers starting
from 100 till 0?

The computer program could be in any
programming language viz C,C++,Java,C#, Python etc.

Thanks & Regards,
Prashant S Akerkar

Last edited by akerkarprash; March 9th, 2019 at 11:25 AM. Reason: Content updates
akerkarprash is offline  
 
March 9th, 2019, 11:34 AM   #2
Math Team
 
topsquark's Avatar
 
Joined: May 2013
From: The Astral plane

Posts: 2,340
Thanks: 983

Math Focus: Wibbly wobbly timey-wimey stuff.
Quote:
Originally Posted by akerkarprash View Post
Reference :

https://www.programiz.com/c-programm...bonacci-series

Can we write a computer program which
will print reverse Fibonacci series numbers starting
from 100 till 0?

The computer program could be in any
programming language viz C,C++,Java,C#, Python etc.

Thanks & Regards,
Prashant S Akerkar
Why are you asking these? Someone gave you a method of printing the numbers in a list backward in another thread. Are you actually asking about Fibonacci numbers rather than programming?

-Dan
Thanks from romsek
topsquark is offline  
March 9th, 2019, 11:40 AM   #3
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: USA

Posts: 2,631
Thanks: 1470

/* generate the Fibonacci series to a list or array */
a[1]=1;a[2]=1;

for(i=3,i<=100,i++){
a[i]=[i-1]+a[i-2];
}

/* read out the array backwards */
for (i=100,i>=1,i--) {
printf("%d\n",a[i]);
}

That might be valid C (it's been decades) but it's better interpreted as pseudocode.

Another method involves knowing $F_{100},~F_{99}$ ahead of time. Then you can do

a[100]=$F_{100}$;
a[99]=$F_{99}$;
for (i=98,i>=1,i--){
a[i] = a[i+2]-a[i+1];
}
romsek is offline  
March 9th, 2019, 11:41 AM   #4
Global Moderator
 
Joined: Dec 2006

Posts: 21,105
Thanks: 2324

The number 100 isn't a Fibonacci number. It wasn't clear what was meant. However, individual Fibonacci numbers are easily calculated.

Last edited by skipjack; March 9th, 2019 at 12:10 PM.
skipjack is offline  
March 9th, 2019, 11:44 AM   #5
Banned Camp
 
Joined: Nov 2018
From: Mumbai

Posts: 32
Thanks: 1

Thanks.

https://www.programiz.com/c-programm...bonacci-series

I want to trace the programming logic
for printing the Fibonacci series in reverse order.

Can we can term this new series as
Reverse Fibonacci numbers series?

Thanks & Regards,
Prashant S Akerkar
akerkarprash is offline  
March 9th, 2019, 11:56 AM   #6
Global Moderator
 
Joined: Dec 2006

Posts: 21,105
Thanks: 2324

Starting with which Fibonacci number?

Fibonacci numbers can be quite large, so the languages you've mentioned might not be good choices.
skipjack is offline  
March 9th, 2019, 11:59 AM   #7
Banned Camp
 
Joined: Nov 2018
From: Mumbai

Posts: 32
Thanks: 1

Thanks.

I feel we should start with 89 till 0 for printing Reverse Fibonacci numbers series.

Next Fibonacci number after 89 is 144 which is greater than 100.

Thanks & Regards,
Prashant S Akerkar
akerkarprash is offline  
March 9th, 2019, 04:19 PM   #8
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 14,597
Thanks: 1039

Ye olde UBasic again:

u=89
v=55
DOWHILE v>0
PRINT u,
w=u-v
u=v
v=w
ENDDO

Output:
89,55,34,21,13,8,5,3,2,1,1
Thanks from topsquark
Denis is offline  
March 9th, 2019, 06:38 PM   #9
Senior Member
 
Joined: Aug 2012

Posts: 2,424
Thanks: 759

Quote:
Originally Posted by Denis View Post
Ye olde UBasic again:

u=89
In order to find the right value of u you had to compute the Fibs forward. This is actually a harder and more interesting situation than the primes. How do you determine the largest Fib number less than some given value?

There turns out to be a closed-form expression for the n-th Fib, you could use that.

A Closed Form of the Fibonacci Sequence - Mathonline
Maschke is offline  
March 9th, 2019, 08:31 PM   #10
Senior Member
 
Joined: Jun 2014
From: USA

Posts: 644
Thanks: 55

If going back from 100, you could just write a sentence of the numbers as text... which I suppose is generally true of any finite initial segment written backwards. Calculating it isn’t hard either as noted above. So long as your calculation of an initial and each successive Fib. is one that can be done in a finite number of steps, and in this case it most certainly is, there is a formula for it.
AplanisTophet is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
fibonacci, program, reverse, series



Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fibonacci vs. prime series Loren Number Theory 2 March 20th, 2018 11:16 PM
Fibonacci-Type series and the number e hfsierra Number Theory 1 April 24th, 2015 09:02 AM
fibonacci series chuackl Elementary Math 2 May 28th, 2014 04:08 AM
reverse n vdrn Number Theory 28 October 22nd, 2011 05:07 PM
What is the summation formula for fibonacci series? mikeleblanc666 Applied Math 1 February 10th, 2009 02:54 PM





Copyright © 2019 My Math Forum. All rights reserved.