LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2015, 08:31 PM   #1
Davidbow23
LQ Newbie
 
Registered: Jun 2015
Posts: 1

Rep: Reputation: Disabled
Smile Using gmc.h library


Here is a little C program I have written to factorise a number - I wish to input larger numbers than long long integers can handle - so I wish to use gmc.h library.
I am finding his a little confusing so If anyone would convert the program below, I would be thankful.

/*
Factorisation program based upon an ealier version written in Pascal. Finds and lists all the
factors in a given integer. Tests if input_number MODULUS testnumber is zero. If so, the test number
and (input number DIVIDED by the test number) is printed and the total number off counted.
There is only the need to for the test number to range from unity to the square root of the input
number. The square root is found is reached when the (input number DIVIDED by the test number)
is <= test number. No floating point routines are used.
*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
unsigned long long int input_num, buff;
unsigned long int test_num =1, factor_cnt = 0;
int column_cnt = 0;

printf ("Enter number to be factorised: ");
scanf ( "%Ld", &input_num);
printf ( "The factors of %Ld are listed below \n\n", input_num );
while (test_num <= (buff = input_num / test_num))
// true while test_num <= SQRT of input_num
{ if ( input_num % test_num == 0)
{ printf ( "%-20Ld", buff);
factor_cnt ++;
if (buff != test_num)
// always true if input_num is NOT a perfect square
{ printf ("%-20ld",test_num);
factor_cnt ++;
}
column_cnt ++;
if ( column_cnt == 2)
{ printf ( "\n" );
column_cnt = 0;
}
}
test_num ++ ;
}

printf (" \nThere are %-10lu different factors in %-20Lu\n", factor_cnt,
input_num);
return (1);
 
Old 08-06-2015, 01:05 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
please post a link to this "gmc.h"

is it GNU Midnight Commander ( GMC)

also please USE the code tags for code
PHP Code:
 [codeplace the code here [/code
Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
unsigned long long int input_num, buff;
unsigned long int test_num =1, factor_cnt = 0;
int column_cnt = 0;
 
Old 08-06-2015, 01:31 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
I think the OP is actually asking about the gmp library. https://gmplib.org/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GMC Link linuxqueric Linux - Desktop 6 12-13-2009 12:09 PM
Icon Problem with GMC on Fluxbox? Truti Linux - Software 0 08-25-2003 01:23 PM
Starting GMC with IceWM yoshi273 Linux - General 1 07-06-2002 06:20 PM
GMC does not load Chukky Linux - Newbie 0 12-03-2001 09:55 AM
change font in gmc icon desktop rainman Linux - Software 0 04-22-2001 12:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration