It is very short.
[csharp]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] fib = new int[255];
fib[0] = 0;
fib[1] = 1;
for(int i = 2; i < fib.Length; i++)
{
fib[i] = fib[i-1] + fib[i-2];
Console.WriteLine(""+ fib[i]);
}
}
}
}[/csharp]
:v:
After the 255nd iteration you can't make your array any bigger, that's why it crashes. I don't have an IDE with me to check why you're getting negative numbers.
Sorry for the shitty explanation.
I have a feeling .length counts from 1 rather than 0.
Post the output, I don't see anything obvious that would cause negative numbers.
It's because the value is getting larger than int.MaxValue, so it wraps around. Use a long instead.
[editline]19th June 2011[/editline]
Or an UInt64.
[QUOTE=Hruhf;30561356]I have a feeling .length counts from 1 rather than 0.
Post the output, I don't see anything obvious that would cause negative numbers.[/QUOTE]
Of course length gives a length of 1 back as 1. Because if you ask me how many elements 3 elemts with index 0 1 2 are, they still are 1 2 3 elements.
[QUOTE=Hruhf;30561356]I have a feeling .length counts from 1 rather than 0.
Post the output, I don't see anything obvious that would cause negative numbers.[/QUOTE]
[img]http://gyazo.com/476b08c552dad2e45760190b1a433ee3.png[/img]
Also, I am trying the long now.
I don't know anything about the types of numbers, didn't really find a page explaining all of them and where to use them.
Edit: tried the long, it has indeed a farther range, but the negatives start coming after 754011380476346429.
[QUOTE=Dlaor-guy;30561366]It's because the value is getting larger than int.MaxValue, so it wraps around. Use a long instead.
[editline]19th June 2011[/editline]
Or an UInt64.[/QUOTE]
Don't ints go up to like 2 billion? I can't picture this going that high.
[editline]19th June 2011[/editline]
Nevermind, I've been proven wrong.
No wait, use a Decimal instead. It can reach values up to 79228162514264337593543950335 :v:
[editline]19th June 2011[/editline]
According to Wolfram Alpha, that's...
[img]http://i.imgur.com/wgfH7.png[/img]
Also I don't need help with the crashing, I just placed a Console.ReadKey(); so I could read it.
Decimal overflows at the number after
30960598847965113057878492344
and
50095301248058391139327916261
which would have made
8.10559001e28 (excuse the e thingy, used the google calculator)
Edit: 50095301248058391139327916261 is the 139th number :science:
Interesting factoid: The entire Fibonacci sequence is contained in the decimal representation of 1/89. It sort of explains [url=http://www.geom.uiuc.edu/~rminer/1over89/]it here[/url].
Wait, what? I only just noticed I was hightlighted. :v: I forgot I even made that thing. Rate me late or something.
[QUOTE=mechanarchy;30561509]Interesting factoid: The entire Fibonacci sequence is contained in the decimal representation of 1/89. It sort of explains [url=http://www.geom.uiuc.edu/~rminer/1over89/]it here[/url].[/QUOTE]
Woah, how is it even possible to discover that?
"Hey, I am going to try and see if the addition of the fibonacci sequence in decimals equals 1/89"
[QUOTE=uitham;30561203]For some reason, after a certain amount, the numbers get negative (WHY!? IT IS IMPOSSIBLE GODDAMNIT).[/QUOTE]
Integer overflow?
[editline]19th June 2011[/editline]
I just
missed half a page?
[editline]19th June 2011[/editline]
[QUOTE=uitham;30561545]Woah, how is it even possible to discover that?
"Hey, I am going to try and see if the addition of the fibonacci sequence in decimals equals 1/89"[/QUOTE]
Maybe someone just put 0.<first few numbers> and noticed it's close to something.
Actually, it's more probable that someone divided 1/89 and noticed that the first few decimals are the first few numbers of the fibonacci sequence.
[QUOTE=esalaka;30561565]Maybe someone just put 0.<first few numbers> and noticed it's close to something.[/QUOTE]
But some overlap so you couldn't just see the Fibonacci sequence in it
[editline]19th June 2011[/editline]
[QUOTE=Darwin226;30561623]Actually, it's more probable that someone divided 1/89 and noticed that the first few decimals are the first few numbers of the fibonacci sequence.[/QUOTE]
Actually, yeah since the first 6 or so are preserved
You can see 1-1-2-3-5 and then 9 which is close enough to 8 to make someone investigate further and notice that the next number in the sequence is 13 which is a 1 and 3 and so on.
What are you working on? v19 - Uitham takes over the second page with the Fibonacci sequence
Google 2's compliment, it has to do with the way computers represent negative numbers ;) I CBA to explain it here there's plenty of better explanations on the internet. To sum it up the last bit of a number in memory represents its minus sign, when a number overflows into that bit it messes with the sign of it.
[QUOTE=SEKCobra;30559243]Hacking (and any other kind of intrusion) is never legal, no matter what intention you have.[/QUOTE]
Hacking refers to modifying something to do what it's not made to. Many forms of hacking are legal such as overclocking or modding.
But in that context, yeah it's illegal.
Thank you for all highlights! Finally more than 20 :D
And happy to see Austech posting again.
[QUOTE=Hruhf;30561798]Hacking refers to modifying something to do what it's not made to. Many forms of hacking are legal such as overclocking or modding.[/QUOTE]
Depends on [url=http://en.wikipedia.org/wiki/Hacker_(hobbyist)]which[/url] [url=http://en.wikipedia.org/wiki/Hacker_(computer_security)]definition[/url] you use. Unfortunately, the word's original meaning has been [url=http://en.wikipedia.org/wiki/Hacker_%28term%29#Hacker_definition_controversy]overshadowed[/url] by the one popularized by the media.
[QUOTE=Hruhf;30561798]Hacking refers to modifying something to do what it's not made to. Many forms of hacking are legal such as overclocking or modding.
But in that context, yeah it's illegal.[/QUOTE]
Making a hard disk play music is hacking too. EDIT: that is, not as file, but as the arm moving around making sound waves
Cracking is illegal. But no one uses that word for intruding anymore.
[QUOTE=Wyzard;30561894]Depends on [url=http://en.wikipedia.org/wiki/Hacker_(hobbyist)]which[/url] [url=http://en.wikipedia.org/wiki/Hacker_(computer_security)]definition[/url] you use. Unfortunately, the word's original meaning has been [url=http://en.wikipedia.org/wiki/Hacker_%28term%29#Hacker_definition_controversy]overshadowed[/url] by the one popularized by the media.[/QUOTE]
Shows how much power the media has.
Hanging up coding for a short while whilst I work on writing a book about game design and theory. This could go so unbelievably wrong.
[QUOTE=Dlaor-guy;30559664]RyanDv3, I don't want to sound like an ass but you put my cool sphere thing by Maurice's highlights :smith:
(see [url=http://www.facepunch.com/threads/1090922-What-are-you-working-on-v18?p=30259816&viewfull=1#post30259816]this post[/url])[/QUOTE]
Oops!
Fixing, sorry
To clarify, the [b]entire[/b] Fibonacci sequence (to infinity) is in 1/89 - it just gets mangled because the digits start to overlap. But the whole thing is there! I'm sure!
Haven't worked much on Orbitals lately, but I did just implement gizmos so you can see the acceleration vector. (Right now the gizmo is twice as long in each dimension as the actual acceleration, so it's more obvious)
[quote]
[url=http://dl.dropbox.com/u/6929441/orbitals3.png][img]http://dl.dropbox.com/u/6929441/orbitals3.png[/img][/url]
[/quote]
[editline]20th June 2011[/editline]
oh and I forgot to mention, [b]yay! I'm in the highlights![/b] :buddy:
I made an application that prints the Fibonacci sequence in rows of # characters.
[img]http://f.cl.ly/items/1m2t1f0u0J000q1D3N2X/Capture.PNG[/img]
Is there a way to get a windows command line that's longer that about 80 characters?
[QUOTE=DeadKiller987;30563368]I made an application that prints the Fibonacci sequence in rows of # characters.
[img]http://f.cl.ly/items/1m2t1f0u0J000q1D3N2X/Capture.PNG[/img]
Is there a way to get a windows command line that's longer that about 80 characters?[/QUOTE]
[img]http://i.imgur.com/B3zVC.png[/img]
[img]http://f.cl.ly/items/06130r2i0j1q3D2T1a1z/Capture.PNG[/img]
Didn't get much larger.
[img]http://img.photobucket.com/albums/v661/chaoselite/gettingbetter.png[/img]
Anyone have any program ideas to give to a starter to get some experience?
Sorry, you need to Log In to post a reply to this thread.