Share your repls and programming experiences

← Back to all posts
#WEEKLY 17 || Fibonacci Sequence WITH NO LOOPS OR RECURSION!
EpicGamer007 (1626)

#WEEKLY 17 || Fibonacci Sequence WITH NO LOOPS OR RECURSION!

This weekly challenge was a toughie.

We had to use no loops or recursion to get the nth Fibonacci number. Unfortunately, the only way to this this was manually. So I did it kind of manually!

I created the most trash website ever to hold all the Fibonacci numbers under 1476 separated by a ,. After 1476, all numbers are "infinity". To access that info I used a java.net.URL object paired with a java.io.BufferedReader object to get the html from the website. After this, I split the html by a , which then gave me a String array. Then after the user enters a number, I give back the n'th number from the array to the user!

I think it's a genius idea and I hope you do to.

Enjoy! And Happy Coding! ;)

JUST SO YOU ALL KNOW, THIS SHOULD BE COMPLETELY ACCURATE! NO APPROXIMATIONS

EDIT: For @TheDrone7 : The repl that is posted here DOES NOT COUNT AS A WEEKLY CHALLENGE SO PLEASE LOOK AT THIS repl INSTEAD!

Comments
hotnewtop
dabs364 (277)

@AbhayBhat you win

LOOK

thats a forked version of your repl

dabs364 (277)

@AbhayBhat look at drones profile...

EpicGamer007 (1626)

@dabs364 , its probably a mistake lol

EpicGamer007 (1626)

@dabs364 , he probably tried to run it but the ended up forking it

EpicGamer007 (1626)

@dabs364 , he hasn't scored a weekly challenge until he write "SCORED" in the comments. So you are still in

dabs364 (277)

You’ll win cuz he copied your repl not mine
Bad cuz I’ll [email protected]

EpicGamer007 (1626)

@dabs364 , i told u already, it was probably an accident, i havent one any challenges so far and I was almost disqualified so don't worry, u still have a chance. ;)

EpicGamer007 (1626)

@dabs364 , yea i only started doing this last month. and i quit after half of it cuz it was too hard

dabs364 (277)

@AbhayBhat this is my 2nd weekly
I decided to do it because it’s a new month.

dabs364 (277)

The other one I did was #14 the [email protected]

EpicGamer007 (1626)

@dabs364 , just wanted to check it out.

dabs364 (277)

/ —

| ......—

| ......—

\ —

potatojs (844)

but wait you didn't calculate the Fibonacci numbers you used an already existing file that contains all the numbers... i think this is off the rules

EpicGamer007 (1626)

@potatojs, is it? hopefully it is not.

EpicGamer007 (1626)

@potatojs, if I really have to, I could change it so that it is an algorithm/equation rather than from an existing file. Though that could result in bad results.

Actually, now that I think about it, what I think I can do is have some numbers be calculated with an equation and some be from the existing file.

potatojs (844)

i think just the equation will give you a lot more point than using already existing data
:P
@AbhayBhat

EpicGamer007 (1626)

@potatojs, maybe... I might convert it to a hybrid model

EpicGamer007 (1626)

@TheDrone7 , can you please confirm if doing this is allowed?

TheDrone7 (1777)

@AbhayBhat no. You're not calculating it as the challenge requires you to.

EpicGamer007 (1626)

@TheDrone7, ok, I will change it and let you know.

EpicGamer007 (1626)

@TheDrone7, I finished my thing with the help of @pepsipu 's python thing. Here, should I repost it or remake this post to have this repl?

pepsipu (38)

no api solution:
https://repl.it/@pepsipu/nth-fib-no-jumpscalls
since phi^n is the ratio of two fib numbers n apart (at infinity), phi^n will be the nth term of the fib sequence * phi + the n - 1 term in the sequence

EpicGamer007 (1626)

@pepsipu, doesn't work. Its off by quite a bit:

vs.

EpicGamer007 (1626)

@pepsipu, Mine is supposed to be exact. Not an approximate guess.

pepsipu (38)

@AbhayBhat i see why you could have thought that! sorry, i should have been more clear. sqrt(5) is irrational, and can only be represented with an infinite amount of computer memory. math.sqrt can only calculate to python's floating point size, so it's not a very good approximation. I've created a new repl where i'm using the decimal library for a better approximation of sqrt(5) (https://repl.it/@pepsipu/fib-no-jumpcall#main.py). this one accurately calculates the fibonacci up to whatever place you'd like, but by default calculates over 2000 terms. i've written an accuracy test for it here: https://repl.it/@pepsipu/nth-fib-no-jumpscalls#main.py. also, you should fix your description! it's misleading to tell people that it contains all the fibonacci terms until infinity, especially since there is an infinite number of fibonacci terms. your website currently has 1476 terms, so maybe rebrand it? hope this helps!

EpicGamer007 (1626)

@pepsipu, if I am making a mistake in my interpretation of your comment, sorry, I am a skim-reader.

pepsipu (38)

@AbhayBhat my program starts with 0 indexed terms, so what you're looking for is index 99.

EpicGamer007 (1626)

@pepsipu, oh i see. you should make that clear.

EpicGamer007 (1626)

@pepsipu, can you please help me get this set up a bit in java?...

SpicedSpices (295)

That's insane. I never would have thought of that genius idea. Kudos to you and good luck

AmazingMech2418 (1039)

So, this is allowed? LOL! I thought it said no external APIs...

EpicGamer007 (1626)

@AmazingMech2418, what do u mean? I don't use any external api's. I used inbuilt libraries

AmazingMech2418 (1039)

@AbhayBhat Well, the website you created could be considered an external API...

EpicGamer007 (1626)

@AmazingMech2418, I don't really know about that.. I created that website so I don't think that would be considered an external api..

DynamicSquid (4626)

Cool! Never thought I'd seen web scrapping in Java

EpicGamer007 (1626)

@DynamicSquid, Thanks! "Web Scrapping". It isn't a new concept. I created the website myself and made it really trashy with no actual HTML so it was really easy to get it. In reality, this is not the way to go. A better way to webscrape is to use JSoup, an external library in java

JosephSanthosh (1171)

Whoever made javascript had to be really engrossed with coffee. @DynamicSquid

EpicGamer007 (1626)

@JosephSanthosh, do you mean java? js is completely different.

EpicGamer007 (1626)

@JosephSanthosh, java is for backend usually and js for front end
They are not the same.

JosephSanthosh (1171)

Wait! So how many different java's are there? @AbhayBhat

EpicGamer007 (1626)

@JosephSanthosh, there is only ONE java. it just so happens that there is another programming language called javascript. THey are not related in any way

potatojs (844)

lmao js and java are different java is...ded
js is the best :) you see?
@JosephSanthosh

EpicGamer007 (1626)

@potatojs, you can't just make that assumption. js and java are for two completely different things so you CANNOT compare them. >:(

JosephSanthosh (1171)

WHAT?!?!? Why couldn't they get a better name??? So annoying. @AbhayBhat

potatojs (844)

lol i'm just kidding :D
you seem like a java fun?
lmao
@AbhayBhat

EpicGamer007 (1626)

@potatojs, what does "you seem like a java fun" mean.

CodeLongAndPros (1589)

@JosephSanthosh
JS is actually called EMCAScript, but JavaScript is the common name. What you are doing is saying arch and artix sound the same, so therefore, they are the same.

potatojs (844)

ohh you are learning p5!
nice
@AbhayBhat

EpicGamer007 (1626)

@potatojs, yea i was really inspired by your projects. ;)

and @CodeLongAndPros, its actually ECMAScript, not EMCAScript

CodeLongAndPros (1589)

@AbhayBhat Uh.
Sad thing is that hpepens a lot

potatojs (844)

yea i was really inspired by your projects. ;)

wow... i never though i'll inspire someone in something else than spaguitty code (my profession)
@AbhayBhat

Codemonkey51 (1048)

JavaScript was made for Netscape navigator (by someone working there) and was inspired by java and scheme (for reasons I won't discuss bc comment would be a mile long for that check wiki here, that is why it's named javascript @JosephSanthosh

JosephSanthosh (1171)

Ohhhhhh, Ok I get it! Wait! Someone here in repl.it made JS? @Codemonkey51

Codemonkey51 (1048)

:facepalm: no someone at Netscape navigator (look it up, it is an old web browser) js was made long before repl I recommend reasereching js histor on your own search up JavaScript history or something @JosephSanthosh

AstOwOlfo (257)

You can’t say java < js. They’re used for completely different things. Except for web apps 9/10 times java > js @potatojs

potatojs (844)

lol i was kidding :D

no i'm not
@agent9002