I am programming some combinatorics questions. Students can enter their answers using P(m,n) and C(m,n) notation, but sometimes students like to enter numbers instead. The integer answers can get quite large, and I want to avoid scientific notation when displaying numbers that arise.

1) Is there a quick and easy way to display integers that are large (ie more than 6 digits) without using scientific notation? I used sprintf. While I have C(m,n) and P(m,n) notation appearing in the ``Correct Answer'' column, I thought it would be nice to show the actual computed number in the solution areas.

2) If the student enters a computed number (rather than an expression using C(m,n) or P(m,n) ), is there a way to ensure the actual correct integer is entered other than setting the tolerance to 0.000001?

Code and embedded questions below:

########################################################################

DOCUMENT();

loadMacros(

"PGstandard.pl", # Standard macros for PG language

"MathObjects.pl",

"PGML.pl",

"contextIntegerFunctions.pl", # need for P(n,k) and C(n,k);

#"PGcourse.pl", # Customization file for the course

);

# Print problem number and point value (weight) for the problem

TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect

$showPartialCorrectAnswers = 1;

##############################################################

#

# Setup

#

#

Context("IntegerFunctions")->flags->set(

# reduceConstants=>0,

reduceConstantFunctions=>0

);

Context()->flags->set(tolerance => 0.000001);

$total =32 ; #random(26,32);

$selection = 25; #random(9,12);

##############################################################

#

# Text

#

#

BEGIN_PGML

How many unordered selections of size [:[$selection] :] can be made from a set of [: [$total]:] objects?

[_]{Formula("C($total, $selection)")}{30}

*Solution* I'm putting the solution here rather than in pgml_solution area to avoid clicking and display my issues when presenting solutions.

[: [@ Formula("C($total, $selection)" ) @] = [@ Formula("C($total, $selection)") -> reduce @] :]

I want to avoid scientific notation when computing the actual number in the solution section. Note: I have the C(m,n) notation appearing in the ``Correct Answer'' column, which is exactly what I wanted. That being said, I needed to crank the tolerance up to 0.000001 to make sure 3365860 was not accepted as a correct answer. Is there a better way to do this?

I tried to use sprintf to get the entire number for [: C([$total], [$selection]) :] with varying results.

Version 1: sprintf with with algebra notation [| [: [@ sprintf("%d",Real(" C($total, $selection) ")-> value ) @] :] |]

[: [@ sprintf("%d",Real(" C($total, $selection) ")-> value ) @] :]

Version 2: sprintf with with latex notation

[| [@ sprintf("%d",Real(" C($total, $selection) ")) @] |]

[` [@ sprintf("%d",Real(" C($total, $selection) ")) @] `]

Version 3: sprintf with with latex and -> value applied to the real number [| [@ sprintf("%d",Real(" C($total, $selection) ") -> value ) @] |]

[` [@ sprintf("%d",Real(" C($total, $selection) ") -> value ) @] `]

Version 3 is what I want. Is there a shorter way to get Version 3 (ie the entire correct large number)?

END_PGML

COMMENT('MathObject version. Uses PGML.');

ENDDOCUMENT();