Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
March 2nd, 2004, 03:54 PM
 reaper69
Contributing User

Join Date: Feb 2004
Posts: 30
Time spent in forums: < 1 sec
Reputation Power: 10
Does this look right for what I want to do??!!??

I am trying to right a program that allows you to type in any number and it will start at 1 and keep doubleing till it gets to the number just for fun.

Code:

def fib(n)

input = "Pick a Number", x
a, b = 0, 1
while b < n
print b;
a, b = b, a+b

fib(x)

#2
March 2nd, 2004, 04:20 PM
Registered User

Join Date: Feb 2004
Location: Germany
Posts: 11
Time spent in forums: 4 h 17 m 25 sec
Reputation Power: 0
Code:
```def fib(n):
n = int(raw_input("Number: "))
b = 1
while b <= n:
print "%d" % int(b)
b = b + 1

fib(n)```

Last edited by Naddel : March 2nd, 2004 at 04:31 PM.

#3
March 2nd, 2004, 04:42 PM
 netytan
Hello World :)

Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Here you have it, just a very simple example... as you said, the number keeps doubleing untill it gets to the limit you supply

Code:
```>>> l = int(raw_input('Enter a number '))
Enter a number 100
>>> n = 1
>>> while n <= l:
print n
n = n * 2

1
2
4
8
16
32
64
>>> ```

Mark
__________________
programming language development: www.netytan.com Hula

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Does this look right for what I want to do??!!??