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....

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

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

there is no specific pass key... you can put anything you want as the pass key.. hope i was helpful :)

Mar 18, 2011 | Computers & Internet

Some telephone-companies offer per-number blocking. I just dial "STAR-SIX-ZERO",

and choose the option to "block last number that called me".

and choose the option to "block last number that called me".

Nov 29, 2010 | Computers & Internet

Re-type the product key in all caps and then in lower case to see if the system will take it. Also, don't confuse the number zero with the letter zero and vice versa. If that don't help, then call Microsoft on the toll free line which you can get from gethuman.com and ask the rep for a product key.

Oct 06, 2010 | Computers & Internet

this would be explained on the basis of two FACTS below.......

sum of two odd numbers are always even and

sum of to even numbers are also always even

then how 6 odd numbers (consider 3 pairs, 9 5 3 1 being odd numbers) can make an odd number 21..!!

SO SIMPLE

Make your basics strong...

sum of two odd numbers are always even and

sum of to even numbers are also always even

then how 6 odd numbers (consider 3 pairs, 9 5 3 1 being odd numbers) can make an odd number 21..!!

SO SIMPLE

Make your basics strong...

Aug 14, 2010 | Computers & Internet

If your system came with a recovery cd and you have lost it, the only things you can do is either , do a system restore back to the last restore point shown. Or purchase a new CD disk.

If yous system did not come with a recovery disk, then it is possible there is a recovery image of windows residing on the D:\ drive partition of your hard drive. If this is the case, when you boot up the computer and it's on the black screen, you should be given an option something like "Press F10 for Setup" . If you press F10 you will have options on how to recover the PC to factory defaults.

If yous system did not come with a recovery disk, then it is possible there is a recovery image of windows residing on the D:\ drive partition of your hard drive. If this is the case, when you boot up the computer and it's on the black screen, you should be given an option something like "Press F10 for Setup" . If you press F10 you will have options on how to recover the PC to factory defaults.

Jun 16, 2010 | Computers & Internet

Well, given that the two "missing" characters are either 0 to 9 or A to Z,

there are 36*36 (1272) different possible combinations.

So, if you are "average", and use "brute-force" attempts, you will have to make 636 attempts. If you are "lucky", you'll get the correct characters in less than 300 attempts.

Good luck!

Hint: Note that "digits" are somewhat rare in each 5-character group.

So, try 'AA' through 'ZZ' before trying any pair that contains a digit.

Try "two-digits" only as a last resort.

there are 36*36 (1272) different possible combinations.

So, if you are "average", and use "brute-force" attempts, you will have to make 636 attempts. If you are "lucky", you'll get the correct characters in less than 300 attempts.

Good luck!

Hint: Note that "digits" are somewhat rare in each 5-character group.

So, try 'AA' through 'ZZ' before trying any pair that contains a digit.

Try "two-digits" only as a last resort.

Sep 14, 2009 | Computers & Internet

This code generates some random number to test.

#include <limits.h>

#include <stdio.h>

#include <stdlib.h>

int main()

{ findLargest();

return 0;

}

int findLargest()

{ int someNumbers[50];

int i;

// to generate some numbers for us to test

for(i=0; i<50; i++)

// generate a random number between 0-100

someNumbers[i] = rand() % 100;

// for keeping track of numbers, set as smallest possible

int largest = INT_MIN;

int largest2 = INT_MIN;

// go through each item in the array

for(i=0; i<50; i++)

{ // if bigger than our previous max, set as new max

if (someNumbers[i] > someNumbers[largest])

largest = i;

// if it's not been set as new max, and is bigger than current 2nd largest

else if(someNumbers[i] > someNumbers[largest2])

largest2 = i;

// for printing all numbers in the array

printf("%d | %d\n",i, someNumbers[i]);

}

// print largest numbers and their position in the array

printf("largest %d (pos %d).\n2nd largest %d (pos %d)",

someNumbers[largest],

largest,

someNumbers[largest2],

largest2

);

return 0;

}

#include <limits.h>

#include <stdio.h>

#include <stdlib.h>

int main()

{ findLargest();

return 0;

}

int findLargest()

{ int someNumbers[50];

int i;

// to generate some numbers for us to test

for(i=0; i<50; i++)

// generate a random number between 0-100

someNumbers[i] = rand() % 100;

// for keeping track of numbers, set as smallest possible

int largest = INT_MIN;

int largest2 = INT_MIN;

// go through each item in the array

for(i=0; i<50; i++)

{ // if bigger than our previous max, set as new max

if (someNumbers[i] > someNumbers[largest])

largest = i;

// if it's not been set as new max, and is bigger than current 2nd largest

else if(someNumbers[i] > someNumbers[largest2])

largest2 = i;

// for printing all numbers in the array

printf("%d | %d\n",i, someNumbers[i]);

}

// print largest numbers and their position in the array

printf("largest %d (pos %d).\n2nd largest %d (pos %d)",

someNumbers[largest],

largest,

someNumbers[largest2],

largest2

);

return 0;

}

May 07, 2009 | Computers & Internet

Convert to UPPER, Proper or lower

Auto Convert to UPPER, Proper or lower

Stop VBA Being Case Sensitive

Select Case Statement. Great alternative to Else If Statements

VBA: CBool(),CByt(),CCur(),CDate(),CDbl()Double,CDec(),CInt(),CLng(),CSng(),CStr(),CVar().

dDate=cDate("25-Jan-07")

Convert Numbers to Words

Convert Numbers to Dollar Amount in Words

Spreadsheet Converter. Versions: HTML/JavaScript,Excel ASP.Net and Excel Java/JSP. $

SQL Database Migration $

Converters. Database Converters, Spreadsheet Converters, Text Converters, E-mail Conversion, Document Conversion, PDF Conversion and more! $

CSV Converter $

Import SQL Into Excel-SQL Tester $

Import Excel Into Access $

Conditional Formatting

More Than 3 Conditional Formats

Conditional Format Fonts for greater than 3

Custom Formats

Excel see a cells format as having four Sections. These are, from left to right: Positives;Negatives;Zeros;Text.

To hide zeros cell-by-cell use a Custom Number Format like

To hide zeros on the Workbook level go to

Dec 15, 2008 | Microsoft Windows XP Home Edition

To start points and lines are not shapes, and a triangle is not representable with a single function, therefore you need a function to draw shapes , given a number of points as parameters, and one to draw math functions (lines etc.).

Here is an example:*Draw* Line, Ellipse, Polygon **...**

From website above, here is script in JS:

"<script type="text/javascript">

<!--

function myDrawFunction()

{

jg_doc.setColor("#00ff00");*// green*

jg_doc.fillEllipse(100, 200, 100, 180);*// co-ordinates related to the document*

jg_doc.setColor("maroon");

jg_doc.drawPolyline(new Array(50, 10, 120), new Array(10, 50, 70));

jg_doc.paint();*// draws, in this case, directly into the document*

jg.setColor("#ff0000");*// red*

jg.drawLine(10, 113, 220, 55);*// co-ordinates related to "myCanvas"*

jg.setColor("#0000ff");*// blue*

jg.fillRect(110, 120, 30, 60);

jg.paint();

jg2.setColor("#0000ff");*// blue*

jg2.drawEllipse(10, 50, 30, 100);

jg2.drawRect(400, 10, 100, 50);

jg2.paint();

}

var jg_doc = new jsGraphics();*// draw directly into document*

var jg = new jsGraphics("myCanvas");

var jg2 = new jsGraphics("anotherCanvas");

myDrawFunction();

//-->

</script>"

Here is an example:

From website above, here is script in JS:

"<script type="text/javascript">

<!--

function myDrawFunction()

{

jg_doc.setColor("#00ff00");

jg_doc.fillEllipse(100, 200, 100, 180);

jg_doc.setColor("maroon");

jg_doc.drawPolyline(new Array(50, 10, 120), new Array(10, 50, 70));

jg_doc.paint();

jg.setColor("#ff0000");

jg.drawLine(10, 113, 220, 55);

jg.setColor("#0000ff");

jg.fillRect(110, 120, 30, 60);

jg.paint();

jg2.setColor("#0000ff");

jg2.drawEllipse(10, 50, 30, 100);

jg2.drawRect(400, 10, 100, 50);

jg2.paint();

}

var jg_doc = new jsGraphics();

var jg = new jsGraphics("myCanvas");

var jg2 = new jsGraphics("anotherCanvas");

myDrawFunction();

//-->

</script>"

Oct 25, 2008 | Computers & Internet

s80 HEADSET ICON ON MAIN SCREEN THAT MOBILE CAN'T SOUND WITHOUT EARPHONE

PLEASE GEVE ME SOLUTON

PLEASE GEVE ME SOLUTON

Sep 21, 2008 | Microsoft Windows Vista Home Premium with...

114 people viewed this question

Usually answered in minutes!

×