当前位置:网站首页>All in one 1086: Jiaogu conjecture
All in one 1086: Jiaogu conjecture
2022-07-01 03:48:00 【Studying hard】
【 Title Description 】
It is called Jiaogu conjecture , For any positive integer , If it's odd , Then take 3 Add 1, If it's even , Divide by 2, The results are repeated according to the above rules , In the end, you can always get 1. Such as , Suppose the initial integer is 5, The calculation process is as follows 16、8、4、2、1. The program requires an integer , Will be processed to 1 The process output .
【 Input 】
A positive integer N(N <= 2,000,000).
【 Output 】
Enter an integer from to 1 Steps for , Each step is a line , The calculation process is described in each part . The last line outputs "End". If the input is 1, Direct output "End".
【 sample input 】
5【 sample output 】
5*3+1=16 16/2=8 8/2=4 4/2=2 2/2=1 End【 Tips 】
no
#include<stdio.h> int main() { int n; scanf("%d", &n); int temp = n; if (n == 1) { printf("End"); } else { if (n % 2 != 0) { n = n * 3 + 1; printf("%d*3+1=%d\n", temp, n); } temp = n; while (1) { n /= 2; if (n != 0) { printf("%d/2=%d\n", temp, n); temp /= 2; } else { printf("End"); break; } if (n % 2 != 0&&n!=1) { temp = n * 3 + 1; printf("%d*3+1=%d\n", n, temp); n = temp; } if (n == 1) { printf("End"); break; } } } return 0; }
边栏推荐
- 访问阿里云存储的图片URL实现在网页直接预览略缩图而不直接下载
- 409. longest palindrome
- Binary tree god level traversal: Morris traversal
- [deep learning] activation function (sigmoid, etc.), forward propagation, back propagation and gradient optimization; optimizer. zero_ grad(), loss. backward(), optimizer. Function and principle of st
- Error: plug ins declaring extensions or extension points must set the singleton directive to true
- [small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation
- [EI search] important information conference of the 6th International Conference on materials engineering and advanced manufacturing technology (meamt 2022) in 2022 website: www.meamt Org meeting time
- 205. isomorphic string
- Leetcode: offer 59 - I. maximum value of sliding window
- 【EI会议】2022年第三届纳米材料与纳米技术国际会议(NanoMT 2022)
猜你喜欢

FCN全卷積網絡理解及代碼實現(來自pytorch官方實現)

LeetCode 128最长连续序列(哈希set)

【TA-霜狼_may-《百人计划》】1.1 渲染流水线

Download and installation configuration of cygwin

[TA frost wolf _may - "hundred people plan"] 1.4 introduction to PC mobile phone graphics API
![Online public network security case nanny level tutorial [reaching out for Party welfare]](/img/66/d9c848a7888e547b7cb28d84aabc24.png)
Online public network security case nanny level tutorial [reaching out for Party welfare]
![[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation](/img/b3/887d3fb64acbf3702814d32e2e6414.png)
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation

Valentine's Day is nothing.

Future of NTF and trends in 2022
![[TA frost wolf \u may- hundred people plan] 1.3 secret of texture](/img/dc/ce2819258632cdcf2e130a4c05600e.png)
[TA frost wolf \u may- hundred people plan] 1.3 secret of texture
随机推荐
392. 判断子序列
【TA-霜狼_may-《百人计划》】1.1 渲染流水线
【TA-霜狼_may-《百人计划》】1.2.2 矩阵计算
Grid system in bootstrap
72. edit distance
【伸手党福利】开发人员重装系统顺序
What happens when a function is called before it is declared in C?
10、Scanner. Next() cannot read spaces /indexof -1
[TA frost wolf _may - "hundred people plan"] 1.4 introduction to PC mobile phone graphics API
Develop industrial Internet with the technical advantages of small programs
389. find a difference
How do I use Google Chrome 11's Upload Folder feature in my own code?
Blueprism registration, download and install -rpa Chapter 1
208. 实现 Trie (前缀树)
【EI会议】2022年国际土木与海洋工程联合会议(JCCME 2022)
[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理
30. Concatenate substrings of all words
Idea plug-in backup table
Test function in pychram
整合阿里云短信的问题:无法从静态上下文中引用非静态方法