Generators are rather familiar objects in Python. Generators supply data on demand. Using Go you can create a generator with a goroutine and a channel. Here the goroutine is an anonymous function within a function, simple to implement. |
+0 forum
1 | ||

If you are browsing this forum, it is a safe assumption to believe you know of the [Fibonacci Series](http://en.wikipedia.org/wiki/Fibonacci_number). After having a couple of minutes, and some random thoughts, I put together a little piece of code that will print this series out to a file. Private Sub FibWrite(ByVal iMax As Int64) Dim sw As New StreamWriter("Path") Dim n0 As Int64 = 0 Dim n1 As Int64 = 1 Try For i = 0 To iMax Dim iTemp As Int64 = n1 n1 = n1 + n0 n0 = iTemp sw.WriteLine(n1) Next Catch ex As Exception MsgBox(ex.ToString) sw.WriteLine(ex.Message) Finally sw.Close() … |
+0 forum
1 | ||

Yes, I know Fibonacci(=sun of a good man) again. Most famous for his series, but who among you all, know that he was the man who introduced to the Western world, the Arabic numeral system(including zero) in 1202 A.D.? The Italian merchands of those days adored it. It was far more easy to work with than the roman numeral system of course. And it is still in use today. I did the series a little different with a calculation that gives you any Fibonacci number from zero up to the 93th one. I guess the Convert method does the rounding. … |
+2 forum
7 | ||

Can any one tell me about fibonacci heap? I have read that it can be implemented using prims algorithm. but i actual i do not know what is fibonacci heap So can any one tell me what is fibonacci heap? how to implement fibonacci heap? what are the applications of fibonacci heap? and some more content on fibonacci heap which make me comfortable to know about it? |
+0 forum
1 | ||

I know this maybe easy but I need help with creating a fibonacci sequence array from a to b. This is my code so far: def FibL(a,b): list = [] if a == 0: return 0 elif a == 1: return 1 else: return FibL(a-1) + (a-2) for i in range(a, b+1): list.append(i) return list When I test it with print(FibL(1,6)), it returns 1. I need it to return [1, 1, 2, 3, 5, 8] |
+0 forum
3 | ||

I bet all Computer Science related courses would learn low level or machine level languanges in due time and in our university we used the portable 80x86 assembler NASM for our Assembly code So here's my experimentation on how to use "functions" and recursion using a Fibonacci Solver as a test case As you may notice the code only output the final outcome of the Fibonacci sequence instead of printing every number for all steps. I might or might not update this depending on my free time and motivation but for now here's what i've done :) |
+0 forum
0 | ||

Pls help me on this. I really dont have an idea of solving this. Here's the question .. 1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100 and also this one 2. write a program that generates the fibonacci series: 1 1 2 3 5 8 13 up to 50th term. I was shocked when i saw this :-O It is not yet taking up. But pls. Help me. Thanks alot.. - Nell |
+0 forum
5 | ||

i have been trying in vain to implement fibonacci in prolog, and so far i've done that in c++,javascript,python and java. but it just irritates me since i'm new to prolog and i just can't code much, because i haven't seen the prolog equivalents of c++'s for loops,if-else statements,basic variable usage etc.. but still i learnt whatever i could from 4-5 books i downloaded off the net, a few university lecture notes,etc. here's my code to print N elements of the fibonacci series ( here N means excluding the first two basic elements of the series, 0,1. [CODE] start:- write('Enter … |
+0 forum
10 | ||

Just wondering, how high can c++ really count? Because I made a fibonacci program, and it starts acting weird and printing negatives at about 10-11 places. With both long, and int variables? Is it impossible to count higher? If not, how? |
+0 forum
11 | ||

I am trying to make a Fibonacci sequence program to display up to the nth term(only positive numbers). For some reason it doesn't seem to work. [CODE]import java.util.Scanner; /** * * @author Toby */ public class Fabonnacci { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Enter the trem of the fabonacci sequence: "); Scanner input = new Scanner(System.in); int term = input.nextInt(); int x =0; int y =0; int output =0; int first3[] = new int[4]; first3[0]=0; first3[1]=1; first3[2]=1; first3[3]=2; for(int i = 0;i<=term;i++){ if(term<=3){ output=first3[term]; System.out.print(first3[term]); }else{ if(i==0){ System.out.print("0,1,1,2"); x=1; y=2; … |
+0 forum
3 | ||

I have a problem getting my assembly program designed to get the first 47 numbers of the fibonacci series to output to a file. I'm not getting any errors except for when opening command window. This is the exact question on my homework problem if this helps : Using Programming Exercise 6 in Chapter 4 as a starting point, write a program that generates the first 47 values in the Fibonacci series, stores them in an array of doublewords, and writes the doubleword array to a disk file. You need not perform any error checking on the file inputoutput because … |
+0 forum
4 | ||

[CODE]var val1=document.getElementById("text_1"); var but_val=document.getElementById("button_1"); var but_val2=document.getElementById("button_2"); var but_val3=document.getElementById("button_3"); function click() { alert("the value is " +val1.value); } but_val.onclick=click; function array() { var length=val1.value.length; alert("length is " +length); var newarr=new Array(); for(var i=0;i<length;i++) { newarr[i]=val1.value[i];//this is the MAIN PART textbox value comes here in array supose value is 1234 alert(newarr[i]); } var c=0; for(var j=0;j<length;j++) { //now i dont know how to to get sum of all numbers in value } alert("the sum is " +c); } but_val2.onclick=array;[/CODE] |
+0 forum
1 | ||

import java.util.Scanner; public class fibonacci{ public static void main(String[] args){ int n=0; int fib = n+1; Scanner X=new Scanner(System.in); System.out.print("Enter # of the term: "); n = X.nextInt(); for (int i=3; i<=n; i++) { i = i-1 + i-2; } System.out.print("Term is: "+n); } } I know the algorithm is wrong, but I just can't seem to figure it out correctly. I'm trying to construct the fibonacci algorithm without recursion and arrays. If anyone could give me suggestions or pointers, it would be much appreciated. |
+0 forum
4 | ||

I want to make a Program that takes two inputs one initial number and one final number for example if I input 1 as the beginning number and 13 as the final, I would like the program to output the Fibonacci sequence: 1,1,2,3,5,8,13.. I hope someone understands it.. Pleease i beg yoou dont put the fibonacci pseudo code I know it very well... Just help me out with this particular problem.. pleease |
-2 forum
3 | ||

Hello, I'm having another problem with assembly. I'm writing a Fibonacci sequence in assembly and I think I got all my stuff set up, but after I try to convert from .m to .s using gm4, I'm getting this here: NONE:0: gm4: ERROR: EOF in argument list Can anyone tell me what I'm doing wrong here? Please let me know about this. Thanks. Here is my code: [CODE]!Data section .section ".data" input: .word 0 !User input yesNo: .byte 0 !Stores the characters of yes and no nl: .asciz "\n" !Does a new line of input intro: .asciz "\nThis program prints … |
+0 forum
0 | ||

Sometimes we need to generate sequence and perform some process on the results. This usually results in some code like this (We'll be using the [URL="http://en.wikipedia.org/wiki/Fibonacci_number"]Fibonacci sequence[/URL] in these examples): [code]void MyMethod() { // What we want to do is output to the screen the first 10 Fibonacci numbers // multiplied by 5 followed by the first 5 Fibonacci numbers multiplied by 3 ResetFibSequence(); for (int i = 0; i < 10; i++) { Console.WriteLine(NextFib() * 5); } ResetFibSequence(); for (int i = 0; i < 5; i++) { Console.WriteLine(NextFib() * 3); } } private fibCurrent = 0; private fibNext … |
+2 forum
2 |

The End.