Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > MS Technologies ( ASP, VB, C#, .NET )
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 05-01-2008, 01:00 AM   #1 (permalink)
ludask
Recruit
 
Join Date: May 2008
Posts: 3
ludask is on a distinguished road
help with finding zeros for 100!

hi all
using VB2005
im trying to write a code to find number of zeros of 100! but cant get it to work properly?
help would be good
heres the code ive done so far

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = 0
Dim num As Integer = 0
Dim start As Integer = 0
Dim theend As Integer = 100


While (start <= 100)

num = start
While (start Mod 5 = 0)
start = start / 5
i += 1

End While
start = num

While (start Mod 2 = 0)

start = start / 2
start += 1

End While

End While

Label1.Text = i





End Sub
End Class
__________________
ludask is offline   Reply With Quote
Old 05-01-2008, 04:48 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
Think about the values here
Code:
While (start <= 100) num = start # num and start equals 0 While (start Mod 5 = 0) # 0 mod 5 is 5, this is never entered start = start / 5 # 0/5 is 0 start is still 0 i += 1 # i is incremented 1, but since we never entered, it will never be incremented End While start = num # since num is the orriginal start value, start is still 0 While (start Mod 2 = 0) # 0 mod 2 is 2, this is never entered start = start / 2 # 0/2 is 0, start will never change start += 1 # start is incremented, but since we never entered start never gets incremented End While End While
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
finding an odd number? itsmytime_24 All Other Coding Languages 1 10-09-2006 07:07 AM
Help finding a book Amaranthine Lounge 4 06-16-2004 11:37 AM
Finding highest value NirTivAal PHP 3 02-11-2004 05:27 AM
Finding the size of an image? Epsilon PHP 2 06-22-2003 02:23 PM
finding precision of data in file Blaqb0x Standard C, C++ 1 09-24-2002 11:01 PM


All times are GMT -8. The time now is 07:22 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle