Register to reply

Factoring of addition?

by jopux
Tags: addition, factoring
Share this thread:
jopux
#1
Mar25-04, 11:24 AM
P: 1
Is there a name for "factoring" addition? For example....let's say I'm working in a basis of all integers greater than 3. I can make 7 from 3+4; 8 from 4+4 or 3+5; 9 from 3+3+3 or 4+5 or 6+3.......

Is there a name for this? And if so...are there computer programs that will generate these sets for me?
Phys.Org News Partner Science news on Phys.org
Bees able to spot which flowers offer best rewards before landing
Classic Lewis Carroll character inspires new ecological model
When cooperation counts: Researchers find sperm benefit from grouping together in mice
matt grime
#2
Mar26-04, 04:03 AM
Sci Advisor
HW Helper
P: 9,396
Look up partition functions.
pig
#3
Apr9-04, 06:10 AM
P: 87
Quote Quote by jopux
are there computer programs that will generate these sets for me?
try this

#include <stdio.h>

#define LOWEST 3

int n, c[1024];
FILE *out;

void add (int pos, int a, int sum) {
	int i;
	c[pos]=a;
	if (sum>n) return;
	if (sum==n) {
		for (i=0;i<=pos;i++) fprintf(out, "%d ", c[i]);
		fprintf(out, "\n");
		return;
	}
	for (i=a;i>=LOWEST;i--) add(pos+1, i, sum+i);
}

int main () {
	int i;
	printf("n: ");
	scanf("%d", &n);
	out=fopen("results.txt", "wt");
	for (i=n-LOWEST;i>=LOWEST;i--) add(0, i, i);
	fclose(out);
	return 0;
}
this is very slow, i'll try to think of a way to make it faster.

if source code is not allowed in the math forum, i am sorry, delete the post.


Register to reply

Related Discussions
Difference between Identical , Equal , Equivalent Calculus & Beyond Homework 9
Typo in Kapusta or Ashok Das ? Formula for thermal propagator Quantum Physics 0