Question about Computers & Internet

1 Answer

I have a problem

How to get the last non zero number is the factorial of a given no. The given no. can have many digits even more than 100? I have to solve this problem in c++ using STL....

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Governor:

    An expert whose answer gotĀ voted for 20 times.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 95 Answers

This is a common starter challenge in college and high school programming classes. While i'm not willing to code it for you, I can show you the methods you'll need to understand in order to approach the problem. The easiest way of doing this is by using a brute force method. Just keep testing the number to see if the remainder after dividing it with a number lower than it is zero. If so, it's a factor.
For example, If the number is 35 then pick a number just one lower than it that's not the number 1. Now divide the two numbers. 35/34 = a number with many decimal places after it, which means its not one of the factors of the number. However, eventually, you'll approach the number 7, and 35/7 = 5. This number has no decimal, meaning it IS a factor of 35, and also the largest non-zero factor of 35. Your algorithm can now stop, since it found the largest non-zero number.
Here's some pseudo-code:
int largestfactor(int number) {
int temp = number;
for(temp - 1; temp>=1; temp--) {
if (number % temp == 0) return temp
}
return temp
}
Something like that, with some bug tweaks will do it. The "%" sign is called a modulus. It's a standard c++ operator. Good luck, and remember to vote Fixya if you liked it.
The wikipedia article that helps you with better and more effecient algorithms can be found here.
Steven

Posted on Sep 17, 2008

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Large factorials ti84


The TI-84 is limited to numbers with at most twelve significant digits.

If you must know the EXACT value of 16!, try this. Calculate 14!. Note the two zeroes at the end. Strip them off by dividing by 100 and remember the two zeroes. Multiply by 15. Strip off the last zero by dividing by 10 and remember that we've now stripped off three zeroes. Multiply by 16. Add the three zeroes at the end to get a fourteen-digit number.

In this particular case the result is exactly what you get by using the FACT function. That's also true for 17!, but it breaks down past that because 18! has more than twelve significant digits.

The whole point of the calculator is to allow you to do calculations with a reasonable degree of accuracy, as opposed to exactly. You'll notice that it can't do a simple operation like dividing 1 by 3 and produce an EXACT answer---only a twelve-digit approximation.

Oct 03, 2012 | Texas Instruments TI84Plus Graphic...

1 Answer

I am having trouble figuring out how to enter problems to find logarithmic functions


Let me give you a general recipe to familiarize yourself with any calculator, if you are averse to reading the manuals.
Most function will work in one of two ways.
1st way
Enter the number, then press the key,; the result is displayed.immediately.

Second way
Press the function key ( a left parenthesis may be displayed) enter the number (close the right parenthesis if there was a left one) press the = or EXE or ENTER keys.

Try the two ways described above to calculate the following values. The answers are given. Here log is he decimal logarithm and ln is the natural logarithm.


log(1)=0
ln(1)=0
ln(2)=0.693147181
log(2)=0.301029996
ln(100)=4.605170186

log(10)=1 (= number of zeros after the 1)
log(100)=2. (= number of zeros after the 1)
log(1000)=3 (number of zeros after the 1)
log(10000)=4 (number of zeros after the 1)

Aug 17, 2011 | Texas Instruments TI-30 XIIS Calculator

1 Answer

Write a program to find factorial of number. Number of digits in factorial can be smaller or equal to 100 digits. Ex: Input: 20 Output 243290200817664000


Since you left open the choice of language, I chose to do this in RPL.

{{ ! }}

where {{ and }} represent the double-arrow program delimiters.

Given 30, this program returns 265252859812191058636308480000000 (assuming I types it correctly).

Feb 15, 2011 | Lands Phones

2 Answers

My lg ku990i is asking for a puk code


sir please call to the related simcard customercare and say the last 6-digit number which is present before the simcard. then they will give the pukcode number to unlock the cellphone...........

Dec 31, 2010 | LG Cell Phones

1 Answer

Combination rotation


3 Digit Combination Lock
31-10-31

  1. NOTE: If your safe DOES NOT have a key, skip Step 3.
  2. Turn the dial to zero.
  3. Insert your key and turn it until the plunger pops out.
  4. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  5. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  6. Turn the dial to the left to the last number (stop the first time on your last number).

  7. Pull the handle down; the door should open.



3 Digit Combination Locks for Security Safes
31-10-31

  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  3. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  4. Turn the dial to the left to the last number (stop the first time on your last number).
  5. Insert the key; turn right.

  6. Pull on the key while it's in the lock to open the door.



3 Digit Combination Locks for Gun Safes
31-10-31

  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  3. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  4. Turn the dial to the left to the last number (stop the first time on your last number).

  5. Pull the handle down; the door should open.



Electronic Locks
31-10-31


  1. Insert the tubular key into the lock to the left of the key pad.
  2. Turn the key all the way to the right until the plunger pops out.
  3. Press the five-digit factory code. The green Proceed light will come on.
  4. Pull the handle down; the door should open.



4 Digit Combination Lock
31-10-31-10


  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) four times to the first number of the combination (pass the first number of your combination three times, stopping on it the fourth time).
  3. Turn the dial to the right (clockwise) three times to the second number of the combination (pass your second number twice, stopping on it the third time).
  4. Turn the dial to the left (counterclockwise) two times to the third number of the combination (pass the third number of your combination one time, stopping on it the second time).
  5. Turn the dial to the right to the last number (stop the first time on your last number).
  6. Pull the handle down; the door should open.
You can find more information about Sentry Safes at www.SentrySafeShop.com

Dec 11, 2010 | Sentry Fireproof Safe

1 Answer

Is pattern to sentry 1230 safe right left righ


3 Digit Combination Lock
31-10-31

  1. NOTE: If your safe DOES NOT have a key, skip Step 3.
  2. Turn the dial to zero.
  3. Insert your key and turn it until the plunger pops out.
  4. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  5. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  6. Turn the dial to the left to the last number (stop the first time on your last number).

  7. Pull the handle down; the door should open.



3 Digit Combination Locks for Security Safes
31-10-31

  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  3. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  4. Turn the dial to the left to the last number (stop the first time on your last number).
  5. Insert the key; turn right.

  6. Pull on the key while it's in the lock to open the door.



3 Digit Combination Locks for Gun Safes
31-10-31

  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) three times to the first number of the combination (pass the first number of your combination two times, stopping on it the third time).
  3. Turn the dial to the right (clockwise) two times to the second number of the combination (pass your second number once, stopping on it the second time).
  4. Turn the dial to the left to the last number (stop the first time on your last number).

  5. Pull the handle down; the door should open.



Electronic Locks
31-10-31


  1. Insert the tubular key into the lock to the left of the key pad.
  2. Turn the key all the way to the right until the plunger pops out.
  3. Press the five-digit factory code. The green Proceed light will come on.
  4. Pull the handle down; the door should open.



4 Digit Combination Lock
31-10-31-10


  1. Turn the dial to zero.
  2. Turn the dial to the left (counterclockwise) four times to the first number of the combination (pass the first number of your combination three times, stopping on it the fourth time).
  3. Turn the dial to the right (clockwise) three times to the second number of the combination (pass your second number twice, stopping on it the third time).
  4. Turn the dial to the left (counterclockwise) two times to the third number of the combination (pass the third number of your combination one time, stopping on it the second time).
  5. Turn the dial to the right to the last number (stop the first time on your last number).
  6. Pull the handle down; the door should open.
You can find more information on your Sentry Safe at www.SentrySafeShop.com

Dec 08, 2010 | Sentry Fireproof Safe

1 Answer

I need help with significant figures 3.414s 10.02s 58.325s 0.00098s


There are 4 sig figs (sfs) in 3.414.
Also,
  • 4 sfs in 10.02
  • 5 sfs in 58.325
  • 2 sfs in 0.00098

The rule I use is the "dot right-moving arrow" rule.
I know it seems weird, but it is a very powerful rule, always reliable!

Here is what you do:
If the number has a dot in it (that is, if it has a decimal in it), imagine an arrow swooshing from left to right through the number. Start counting sig figs as soon as the imaginary arrow strikes a non-zero digit. Every digit the arrow goes through after it hits that first non-zero digit, is a significant digit (sig fig). The total number of sig figs is the sum of the first non-zero digit + all the following digits the arrow goes through after that. Very simple, right?

As an example, in 0.00098, the arrow sweeps through the leading zeros without counting until it stikes the first nonzero digit, 9. (BONK!!) So you must count it and the following digit (8). So the total number of sfs is only 2 for this number. Try it on the other numbers for practice.

For a better closure, I guess I should explain the other related rule for sig figs:
The "no-dot left arrow" rule. You can use this rule when a number does not have a decimal in it. For example, the number 500 s. (I am using the same unit you gave in your quantities. As you can see, no decimal is shown. So you can not be sure the number has 3 sfs or not. It would only have 3 sig figs if you were informed it was an exact number. An exact number is a number which has been obtained by counting every object it represents. As in a classroom filled with 200 students, each one counted by their teacher during roll call.

To apply the no-dot left-moving arrow rule, simply imagine an arrow moving left until it hits the first non-zero digit. In this case, that digit is the 5, which is only one digit. Therefore, there is only 1 sig fig in 500 s.

Suggestion: Google up "sig figs" and get some more examples of quantities to practice counting sig figs. Also pay attention to the important related topic of proper rounding off of calculated quantities which have different numbers of sig figs. You will find this skill invaluable when you take a lab based chemistry or physics course!

Good luck!

###

Oct 11, 2010 | Scientific Explorer My First Chemistry Kit

1 Answer

Photo No back to zero


FILE NAME..................................................Resetting the file names of pictures
RESET This method is useful when grouping files on separate cards.
The file number and folder number are reset every time a new card
is inserted in the camera. The folder number returns to [No. 100]
and the file number returns to [No. 0001].
AUTO This method is useful when you want to manage all your files
with sequential numbers.
Even if a new card is inserted, the folder number and file number are
retained from the previous card. This helps you to manage multiple cards.

To do this you go to the menu and to the setup option and press ok. Down arrow to file name and pick the option you want to use and press ok.

Apr 07, 2009 | Olympus Stylus 720 SW Digital Camera

1 Answer

Need help in Special Formatting Number


Here is one solution. You might consider adding more robust error handling.
if the decimal numbers passed to the div function are multiples i will be a non-zero number of that multiple otherwise i will be zero.

Dim i As Integer
i = div(12, 0)
If i = 0 Then
'not multiple
' do this
Else
' is multiple
' do something else
End If


Function div(ByVal numerator As Object, ByVal denominator As Object) As Integer
dim n , d decimal
Dim result As Decimal
Dim remainder As Decimal

If IsNumber(numerator) Is True _
And IsNumber(denominator) Is True Then
If numerator <> 0 Then
n = numerator
d = denominator
Else
GoTo error1
End If
Else
GoTo error1
End If
result = Decimal.divide(n, d)
remainder = Decimal.remainder(n, d)
If remainder = 0 Then
div = result
Else
div = 0
End If

Exit Function
error1:
msgbox("Numbers must be non-zero numerics", , "Multiple check error")
div = 0
End Function

End Function

Aug 06, 2008 | Computers & Internet

2 Answers

Factory settings


GOTO: menu ,...settings and tools ... phone settings ... security ... (if you didn't set a pin number then it's the last 4 digits of your phone number OR 4 zero's )

There should be an option to reset the phone.

Nov 23, 2007 | LG VX8300 Cellular Phone

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

115 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...