Question: The question was to find the factorial and this is what I did

```
//Factorial of n numbers

#include<stdio.h>
int main()
{
    int num, i, fact, s;
    printf("Enter the value: ");
    scanf("%d",&num);
    fact = num;
    i = num;
    while(i>1)
    {
        s = i-1;
        fact = fact * s;
    }
    i--;

    printf("The factorial of the number is %d.",fact);
}

```

Hii, I was trying to find the factorial of a number n. The code is not showing any error but I am not getting the required solution. The output screen showed nothing but the input statement. What is wrong with my code? If anyone could help, that would be great.

Thank you in advance!

Answer: 
Here is a simplified answer to the accepted answer:

```r
library(tidyverse)

df |>
  group_by(subs_id) |>
  summarise(
    ttl_amount = sum(amount),
    amount= sum(amount[flag == "taker"]))
#> # A tibble: 3 x 3
#>   subs_id ttl_amount amount
#>     <dbl>      <dbl>  <dbl>
#> 1       1         25     10
#> 2       2         30      0
#> 3       3         30     20

```
Here's how I would do it:

```
library(dplyr)

subs_id <- c(1, 1, 2, 3, 3)
amount  <- c(15, 10, 30, 20, 10)
flag <- c("target", "taker", "target", "taker", "target")

data <- data.frame(subs_id, amount, flag)

data_new <- data %>% group_by(subs_id) %>% 
  mutate(column_summary = sum(amount))

data_new$column_id <- ifelse(data_new$flag == "taker", data_new$amount, 0)

```