Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C# PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1. create unsigned integer array of 5000 elements. Example: const int size = 5000; uint[] factorial = new uint[size]; 2. create an

USE C# PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1. create unsigned integer array of 5000 elements. Example: const int size = 5000; uint[] factorial = new uint[size]; 2. create an variable for store last element index in array to know the most left element whith value 3. using do...while loop for enter interact procedure do { - set array elements to 0. - ask the user to enter number for compute factorial or -1 to exit program. - take the number to compute factorial by passing array and number to "ComputeFactorial" mehtod. // ComputeFactorial(?, ?, ?); - Display result to screen by call "Display" method. } while(number equal or not to -1)

static void ComputerFactorial( ? , ? , ?) { - set first element in result array to 1. (index 1 or index N-1) - set last_element index variable to 1. - set carray to 0; - apply simple factorial formula, N! = 1 * 2 * 3 * 4...... * N-1. - two loops to control the computation sequence outer loop: for how many mutiply operation for compute factorial number (index should begin with 2) { inter loop: compute factorial number and store the result into factorial array { - using factorial formula to compute one element result = element of array * outer loop index value + (uint) carry; - you need to check the result for 6 digits or beigger (it is check for carry or not) if(result > 999999) { -you need to compute carray. -compute correct value to store in the current element of array } else { -store result into the current element of array. -set the carry to 0; } } if you still have carry value (carry is greater then 0) { -increment last_element index by 1. -store carry to last_element in factorial array; -set carry to 0; } decrement last_element by 1. } }

static int ComputeFactorial( ?, ? ) { declare last_element variable; return last _element; }

static void Display( ? , ? ) { declare local variables here set count to 0. Write the message "The big factorial of N is : " loop set index it to last_element, then check i greater than equal to 0. { if(index i equal to last_element) { if(array of index i value not equal to 0) { -check value in array element i has how may digits if(value in factorial[i] is less than 10) Write 5 space characteras befor the value to screen. else if(value in factorial[i] is less than 100) Write 4 space characteras befor the value to screen. else if(value in factorial[i] is less than 1000) Write 3 space characteras befor the value to screen. else if(value in factorial[i] is less than 10000) Write 2 space characteras befor the value to screen. else if(value in factorial[i] is less than 100000) Write 1 space characteras befor the value to screen. else Write the value in factorial[i] to screen } } else { if(value in factorial[i] equal to 0) Write 6 zero characteras to screen else if(value in factorial[i] less then 10) Write 5 zero characteras to screen else if(value in factorial[i] less then 100) Write 4 zero characteras to screen else if(value in factorial[i] less then 1000) Write 3 zero characteras to screen else if(value in factorial[i] less then 10000) Write 2 zero characteras to screen else if(value in factorial[i] less then 100000) Write 1 zero characteras to screen } increment count by 6 Write " " to screnn (optional) if(count value equal to 60) { Write " " to screen. reset the count to 0. } decrement index of array i by 1. } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions