Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Alternativquelltext Primfaktoren, steige da nicht durch :(

Empfohlene Antworten

Veröffentlicht

Hallo kann mir vllt jemand diesen Quelltext erklären? Das wäre supernett...

also so das ich es verstehe als sagen wir mal leihe oder jmd mit grundkenntnissen in C (Ich weiß schon was Felder, Funktionen etc sind, deklaration, variablen etc aber kann diesen Quelltext nicht kommentieren und ihn auch nicht erklären)!

/* Primfaktorzerlegung einer positiven natuerlichen Zahl n */

#include <stdlib.h>

#include <stdio.h>

void div_potenz(unsigned int *, unsigned int);

int main( ) {

unsigned int n,i,l;

unsigned int r[3]={2,3,5},

q[8]={7,11,13,17,19,23,29,31};

printf("\nBerechnung der Primfaktorzerlegung \

von n\n\n");

printf("n = ");

scanf("%u",&n);

if (n!=1) {

printf("Die Primfaktoren von %u sind:\n\n",n);

for (i=0; i<3; i=i+1) {

div_potenz(&n,r);

}

l=0;

do {

for (i=0; i<8;i=i+1) {

div_potenz(&n,30*l+q);

}

l=l+1;

} while ((30*l+7)*(30*l+7)<=n);

if (n>1) {

printf("%u Exp.: 1\n",n);

}

}

exit(EXIT_SUCCESS);

}

/* Pruefen, ob p|x, Bestimmen und Herausdividieren der

* groessten p-Potenz */

void div_potenz(unsigned int *x, unsigned int p) {

unsigned int e=0;

while (*x%p==0) {

e=e+1;

*x=*x/p;

}

if (e>0) {

printf("%u Exp.: %u\n",p,e);

}

}

Danke :):uli

Gast
Dieses Thema ist für weitere Antworten geschlossen.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.