Lab3 - Java Programming Lab 3 & !5 " k =1 % Question 1:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Programming Lab 3 Question 1: Quick Rule for Final Zeros in a Factorial Follow-Up: From our class discussion, the number of final zeros in n ! was seen to be: FZ ( n ) = n 5 k ! " ! # $ # k = 1 % where the brackets denote the floor function. The infinite sum can be truncated as soon as 5 k exceeds n , as all the subsequent terms are zero. In Java, the floor function is automatically obtained by computing the division using integers. Here is a modified method that could compute the number of final zeros in n ! for any number up to 1000!. Here are selected results: FZ(100) = 24, FZ(200) = 49, FZ(1000) = 249 Do you notice a pattern? In class we noticed that an approximate answer can be obtained by noting that the number of zeros is strictly less that n /4. In java we can implement this quick rule as: int quickZeros = (n-1)/4; The quick rule follows simply by removing the floor function and using the formula for a geometric series. FZ ( n ) = n 5 k ! " ! # $ # k = 1 % < n 5 k k = 1 % = n 1 5 k – 1 k = 0 % ( ) * + , - = n 1 1 . 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/17/2012 for the course ECE 203 taught by Professor Robincarr during the Fall '07 term at Drexel.

Page1 / 3

Lab3 - Java Programming Lab 3 & !5 " k =1 % Question 1:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online