<html>
<head>
<title>asp</title>
</head>
<%
dim f1,f2,f3,c
f1=0
f2=1
response.Write(f1 &"<br>")
response.write(f2 &"<br>")
c=1
while(c<=10)
f3=f1+f2
response.write(f3 &"<br>")
c=c+1
f1=f2
f2=f3
wend
%>
</html>
Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.
CLS a = 0 b = 0 FOR i = 1 TO 10 IF a = 0 THEN f = 1 END IF PRINT f b = a a = f f = a + b NEXT i END from : Parth jani parthjani7@yahoo.com
The Fibonacci sequence uses recursion to derive answers. It is defined as: F0 = 0 F1 = 1 Fn = F(n - 1) + F(n -2) To have this sequence printed by a php script use the following: function fibonacci($n) { if($n 1) return 1; //F1 else return fibonacci($n - 1) + fibonacci($n - 2); //Fn } This recursive function will print out the Fibonacci number for the integer n. To make it print out all the numbers in a particular set add this to your script. for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } So your final result would look like. <?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } ?>
write a program to print the series 1/12+1/22+.........+1/n2 ?
The Fibonacci series is a sequence of numbers, with the first two defined as 0 and 1, and all following numbers defined as the sum of the two previous numbers. The following python program asks a user how many Fibonacci numbers they want calculated, then calculates them. NOTE: This site removes formatting from answers. Replace (tab) with a tab, or four spaces. #!/usr/bin/python print("This program finds Fibonacci numbers.") answer = "y" while answer == "y": (tab)print("How many terms would you like?") (tab)n = int(input(": ")) (tab)a = 0 (tab)b = 1 (tab)for i in range(0,n): (tab)(tab)print(str(a) +",") (tab)(tab)c = a + b (tab)(tab)a = b (tab)(tab)b = c (tab)print("Would you like to run again? (y/n)") (tab)answer = input(": ")
#include<iostream> unsigned fib (unsigned term, unsigned a=0, unsigned b=1) { if (term<1) return a; return fib (--term, a+b, a); } int main() { std::cout << "Fibonacci (1000th term): " << fib (1000) << std::endl; }
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
to print the Fibonacci series until 100 you can take the input in d to make it run for whatever value you want void main(){ int a,b,c,d; a=0; b=1; c=1; d=100; while(c<d) { printf("%d\n",c); c=a+b; a=b; b=c; } }
//WAP to print fibonacci series using do-while loop.? using System; class Fibonacci { public static void Main() { int a=1,b=1; int sum=0; Console.Write("Enter Limit:"); int n=Int32.Parse(Console.ReadLine()); Console.Write(a); Console.Write(b); do { sum=a+b; a=b; b=sum; Console.Write(sum); } while(sum<n); } } By-Vivek Kumar Keshari
i=0 j=0 sum=1 limit = ARGV[0] while sum < limit print sum i = j j = sum sum = i + j end
void main() { int n,old=0,curr=1,new=0; clrscr(); printf("enter the total number of terms up to which you want to print the Fibonacci series"); scanf("%d",&n); printf("%d",old); printf("\n%d",curr); for(i=1;i<=n;i++) { new=old+curr; old=curr; curr=new; printf("\n%d",new); } getch(); }
class Fibonacci { public static void main(String args[]) { System.out.println("enter the number upto u want"); int number=Integer.parseInt(args[0]); int a=0,b=1,c=0; System.out.print(a+" "+b); for(int i=1;i<=number;i++) { c=a+b; System.out.print(c+" "); a=b; b=c; } } } the number are given to the run time where are print the series eg: 5 0 1 1 2 3 5 8 13................